How to add migration in .NET Core Library project in web API core 1.1

≯℡__Kan透↙ 提交于 2019-12-11 08:48:54

问题


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:


回答1:


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://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db



来源:https://stackoverflow.com/questions/45440413/how-to-add-migration-in-net-core-library-project-in-web-api-core-1-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!