-
Notifications
You must be signed in to change notification settings - Fork 347
Open
Description
Hey! Great Course BTW.
There is one thing I found so cumbersome that I had to go out of my way to fix it on my project, the commenting/uncommenting for migration to use SqlServer.
Here's how I handled it (note, my project is a "no startup" project, so some minor adaptation would be required in Startup).
In Program.cs
var dbProvider = builder.Configuration.GetValue("Provider", "InMemory");
if(builder.Environment.IsProduction() || dbProvider == "SqlServer") {
// AddDbContext using SqlServer Database
} else {
// AddDbContext using InMemory Database
}
When generating migrations
dotnet ef Migrations add {MigrationName} -- --provider SqlServer where {MigrationName} is the name of the migration you want to add.
Such a simple fix to avoid commenting/uncommenting every times you want to add a migration I thought I would share.
Metadata
Metadata
Assignees
Labels
No labels