ASP.NET Core 5.0
1、新建项目
Ctrl+Shift+N
ASP.NET Core Web
WebApi
F5
2、所需NUGET包
Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.Tools
Microsoft.EntityFrameworkCore
Pomelo.EntityFrameworkCore.MySql (5.0.0-alpha.2)
Microsoft.Bcl.AsyncInterfaces
错误
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use ‘EntityFramework6\Add-Migration’ for Entity Framework 6.
var connectionString = Configuration.GetConnectionString("MySql");
services.AddDbContext<MyDbContext>(options => options.UseMySql(connectionString, MySqlServerVersion.LatestSupportedServerVersion));
EntityFrameworkCore\Add-Migration init
EntityFrameworkCore\Update-Database -verbose