-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
After rerunning the scaffold-dbcontext in EF Core 7 I stumbled upon an issue that does not seem to be documented in breaking change or anywhere else for that matter.
Include your code
This is the code that the scaffold-dbcontext creates in EF Core 6
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
optionsBuilder.UseNpgsql("Host=localhost:5432;Database=SetupPlatform;Username=kolektor;Password=setup");
}
}
As you can see there is an if present which only runs the code with the generated connnection string if optionsBuilder instance is not present.
EF Core 7 however does this and this makes our solution to no longer work (database not found), since the connection string provided at startup through configuration is not applied due to the missing if statement:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
=> optionsBuilder.UseNpgsql("Host=localhost:5432;Database=SetupPlatform;Username=kolektor;Password=setup");
This change only brings trouble and lost time to devs.
Apparently this is not the only such change in EF Core 7
https://stackoverflow.com/questions/75422460/can-i-force-entity-framework-core-7-to-not-make-icollections-read-only/75422780#75422780
Someone apparently gives little thought to this sort of things resulting in wasted development time.
Include provider and version information
EF Core version: 7.0.3
Database provider: either SqlServer or Npgsql
Target framework: .NET 7.0