关于ASP EntityFramework 启用迁移 Enable-Migrations 报异常 "No context type was found in the assembly"

关于ASP EntityFramework 启用迁移 Enable-Migrations 报异常 “No context type was found in the assembly”

在尝试进行对原本数据库进行更新并扩展User.Identity的可用属性时,需要启用迁移 Enable-Migrations,在工具》NuGet packge manager 》Package Manager Console中输入Enable-Migrations。

但是如果你的项目中有多个context,直接使用Enable-Migrations就会报错:

More than one context type was found in the assembly ‘yourApplication’.
To enable migrations for ‘yourApplication.Models.ApplicationDbContext’, use Enable-Migrations -ContextTypeName yourApplication.Models.ApplicationDbContext.
To enable migrations for ‘yourApplication.Models.Model1’, use Enable-Migrations -ContextTypeName yourApplication.Models.Model1.

报错信息在提示你需要指定启用迁移的context,按理来说使用提示给出的指令即可完成制定context的迁移启用如下:

Enable-Migrations -ContextTypeName yourApplication.Models.Model1.

但是我在尝试中发现直接给出的复制指令会报出:

context type ‘yourApplication.Models.Model1.’ was not found in the assembly ‘oxhainanReeTest3’.

最终发现直接复制提示指令,句尾包含了一个句号。。。(气出猪叫)
删除句尾句号后,将context名作为Enable-Migrations的一个参数,加上双引号“”。
测试成功。

Enable-Migrations -ContextTypeName “yourApplication.Models.ApplicationDbContext”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值