实体框架-在程序集中找不到迁移配置类型 [英] Entity Framework - The migrations configuration type was not be found in the assembly
问题描述
在C#项目中,我有多个dbcontext,当我指定完整命令(即:
I have multiple dbcontexts in a C# project and I'm trying to enable migrations, when I specify the full command ie:
启用迁移-ContextTypeName Models.Account.AccountDetailDbContext"
"Enable-Migrations -ContextTypeName Models.Account.AccountDetailDbContext"
使用配置类创建一个迁移文件夹
A migrations folder is created, with the configuration class
然后我收到一条消息:
正在检查上下文是否以现有数据库为目标..."
"Checking if the context targets an existing database..."
然后
在程序集"Portal.WebUI"中找不到迁移配置类型"Portal.WebUI.Migrations.Configuration"."
"The migrations configuration type 'Portal.WebUI.Migrations.Configuration' was not be found in the assembly 'Portal.WebUI'."
即使它只是创建了文件,也找不到它.
Even though it has just created the file it can't find it.
有人可以帮忙吗?
我在程序包管理器控制台"中选择了正确的项目
I have the correct project selected in the Package Manager Console
我尝试使用-verbose命令,但未提供其他信息
I have tried the command using -verbose, but it gives no additional information
如果我将dbcontexts和类复制到一个新项目中,那么所有工作都将奏效,因此在现有项目中一定是使迁移失败的原因,但是我无法确定它是什么.
If I copy the dbcontexts and classes into a new project then it all works, so it must be something in this existing project that it making the migration fail, but I can't tell what it is.
预先感谢您的回答
推荐答案
我设法通过卸载EF nuget软件包然后重新安装来解决此问题.
I managed to resolve this by uninstalling the EF nuget package and then reinstalling it.
挺烦人的...但是我希望它可以帮助其他人.
Rather annoying...but I hope it helps someone else.
这篇关于实体框架-在程序集中找不到迁移配置类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!