1.安装 EntityFramework Core;EntityFramework Core.SqlServer;EntityFramework Core.Tools
2.appsettings.json文件中添加数据库连接字符串
"ConnectionStrings": {
"SqlServer": "Data Source=.;Initial Catalog=note;User Id=sa;Password=sa;"
}
3. startup.cs 文件中ConfigureServices()方法中注册数据库lia连接服务
var connection = Configuration.GetConnectionString("SqlServer");
services.AddDbContext<NoteContext>(options => options.UseSqlServer(connection,b=> b.MigrationsAssembly("NetNoteproject")));
MigrationsAssembly("项目名“)//项目名千万名错了
3.程序包管理器控制台中运行 Add-Migration Note //Note是数据库名称
4.Update-DataBase //应用到数据库修改