When working with migrations in Entity Framework Core, what we usually do is first create the migration and then apply it to the database.
It has always been a two-step process, and that can be a bit annoying when you are continuously developing.
dotnet ef
dotnet ef migrations add Initial dotnet ef database update
Package Manager Console/PowerShell
Add-Migration Initial Update-Database
But with EF Core 11.0, we can create and apply the migration in a single step.
dotnet ef
dotnet ef database update Initial --add
Note the new --add argument.
Package Manager Console/PowerShell
Update-Database -Migration Initial -Add
This will create a migration named Initial and apply it to the database in
one go. The migration files will still be created and saved, so you can
push it along with your code
Since EF Core 11.0 is still in preview, if you are using the
global EF tool, make sure it is updated to the latest version.
dotnet ef --version dotnet tool update --global dotnet-ef
Happy Coding.
Regards,
Jaliya
Jaliya
No comments:
Post a Comment