1

I am new in .net core. I am adding migration in .net core Liabrary project in web API core 1.1. using below code.

Add-Migration example1

But it's showing below error:enter image description here

ruffin
  • 16,507
  • 9
  • 88
  • 138
Sumit Singh
  • 59
  • 1
  • 9

1 Answers1

3

If you are using VS Code or other editor:

In dotnet command cli type:
dotnet ef migrations add InitialCreate

obs:InitialCreate is the name of migration, you can give any name.

If you are using Visual Studio:
Create your database
Once you have a model, you can use migrations to create a database.
Open the PMC:
Tools –> NuGet Package Manager –> Package Manager Console
Run Add-Migration InitialCreate to scaffold a migration to create the initial set of tables for your model.
If you receive an error starting The term 'add-migration' is not recognized as the name of a cmdlet, close and reopen Visual Studio. Run Update-Database to apply the new migration to the database. This command creates the database before applying migrations.

Source: https://learn.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db

  • If using `dotnet ef` with VS Code, some good setup instructions [here](https://learn.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet). – ruffin Feb 14 '18 at 18:08