Home > Mobile >  Entity Framework version 6 using in ASP.NET Core 6.0 not creating the Database in the SQL Server aft
Entity Framework version 6 using in ASP.NET Core 6.0 not creating the Database in the SQL Server aft

Time:06-07

The database is not getting created after Add-migration command when using ASP.Net Core 6.0 web application.

Connection string given below (i am using local db for testing/learning purpose)

"ConnectionStrings": { "DefaultConnection": "Server=(localdb)\local; Database=PradeepShopping; Trusted_Connection=True" }

The database is not getting created.

CodePudding user response:

Hi you need to do another step.

After "add-migration", you have to call "update-database"

CodePudding user response:

  1. Run view -> terminal in Visual Studio.
  2. Type cd ./{your projectname with migrations}.
  3. Run dotnet ef database update.

Done.

p.s.

To rollback database or apply specify migration use: dotnet ef database update {migration name}

  • Related