实体框架代码首次迁移 - 启用迁移失败 [英] Entity Framework Code First Migrations - Enable-Migrations fails

查看:265
本文介绍了实体框架代码首次迁移 - 启用迁移失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用代码优先迁移,并且取得了有限的成功,但我遇到的其中一个问题是我没有告诉它哪个项目具有配置信息。它为我生成了一些类,并且我有一些工作,但我想我应该整理配置问题并重新开始。

I have been trying to use code-first migrations, and had some limited success, but one of the things I got wrong was that I failed to tell it which project had the config information. It generated some classes for me, and I sort-of got it all working, but I figured that I should sort out the configuration issue and start over.

错误。现在我试图删除所有迁移的东西,我发现我不能重新安装它。我已经卸载并重新安装了EF 5,但是当我使用启用迁移命令时,我收到了一个例外报告:

Bad mistake. Now that I've attempted to remove all the migrations stuff, I find I cannot re-install it. I've un-installed and re-installed EF 5, but when I use the Enable-Migrations command, I get an exception report:


System.Runtime.Serialization.SerializationException:类型不是
解决成员
'System.Data.Entity.Migrations.Design.ToolingFacade + GetContextTypeRunner ,EntityFramework,
Version = 4.4.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'。

System.Runtime.Serialization.SerializationException: Type is not resolved for member 'System.Data.Entity.Migrations.Design.ToolingFacade+GetContextTypeRunner,EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

无论我做什么现在,我似乎不能过去。任何想法?

No matter what I do now, I can't seem to get past that. Any ideas?

推荐答案

嗯,我不知道为什么这不是一个问题,事实证明,这个问题是由于我有一些项目针对.NET 4.5和一些目标.NET 4.0引起的。这意味着这些项目使用不同版本的EF 5(v5对v4.4),我认为这是导致问题的;它正在尝试加载DLL的错误版本。

Well, I don't know why this wasn't a problem from the get-go, but it turns out that the issue was caused by my having some projects targetting .NET 4.5 and some targetting .NET 4.0. This means that those projects use different versions of EF 5 (v5 versus v4.4), and I think that was causing the problem; it was attempting to load the wrong version of the DLL.

当我从我的解决方案中卸载定位.NET 4.5的项目时,我可以在目标项目上使用启用迁移.NET 4。

When I unloaded the projects targetting .NET 4.5 from my solution, I could use Enable-Migrations on the projects targetting .NET 4.

这篇关于实体框架代码首次迁移 - 启用迁移失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆