本人EF CORE新手一个,所以针对碰到过的BUG做一个总结。
1.使用时碰见BUG:Both Entity Framework Core and Entity Framework 6 are installed.
解决方案:PM>EntityFrameworkCore\Add-Migration MyFirstMigration -Context MyDbContext
在执行Add-Migration时前面加一个EntityFrameworkCore;并且执行update-database也需要加;
以下多个问题如果碰到 可以私信我寻求帮助,这里主要针对1作答
Unable to create an object of type 'MyDbContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728;
No database provider has been configured for this DbContext. A provider can be configured by overriding the 'DbContext.OnConfiguring' method or by using 'AddDbContext' on the application service provider. If 'AddDbContext' is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.
More than one DbContext was found. Specify which one to use. Use the '-Context' parameter for PowerShell commands and the '--context' parameter for dotnet commands.
Your target project 'Project2.EntityFramework.Core' doesn't reference EntityFramework. This package is required for the Entity Framework Core Tools to work. Ensure your target project is correct, install the package, and try again.
No migrations configuration type was found in the assembly 'Project2.Web.Entry'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).