EF Core 3.1 migrations

Viewed 30

I have a sample application (mdbootstrap.netcore-integrations) that asks me to run the following 2 commands for database migrations

https://mdbootstrap.com/docs/standard/integrations/admin-dashboard-net-aspnet/

dotnet-ef database update

as per the documentation expected behaviour is __efMigrationsHistory table as well as the model tables will be created.. but only the __efmigrationsHistory table is actually created.

Second command is

dotnet-ef migrations add [migrationName] 
dotnet-ef database update

Result is:

Build started...
Build succeeded.

Specify --help for a list of available options and commands.

Unrecognized command or argument 'dotnet-ef'

After this I also tried the following command

Add-Migration InitialCreate

Result:

An operation was scaffolded that may result in the loss of data. Please review the migration for accuracy.

Finally I tried

Update-Database

Result:

relation "Users" does not exist

What will be the correct command/commands to run a proper migration? This is using a code-first approach

1 Answers

With the help of my colleague, I was able to resolve it as follows:

remove-migration
dotnet-ef database update
add-migration Initial
update-database
Related