第一次使用EF CORE碰见的问题

本人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).
 

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值