“启用的迁移”升级到.NET 4.5和EF 5失败后, [英] 'Enable-Migrations' fails after upgrading to .NET 4.5 and EF 5

查看:128
本文介绍了“启用的迁移”升级到.NET 4.5和EF 5失败后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级我的MVC4项目.NET 4.5和EF5使用VS2012开始。
实现后,我需要建立自动迁移的软件包管理器,我再次跑到启用的迁移 - EnableAutomaticMigrations 和收到的错误

I just upgraded my MVC4 project to .NET 4.5 and EF5 and started using VS2012. After realizing I needed to set-up auto-migrations in the Package Manager again I ran Enable-Migrations - EnableAutomaticMigrations and received the error

没有上下文类型在程序集MySolutionName。

曾表示,它与EF5不会让做prereleases。我跑了安装封装的EntityFramework -Include $ P $租赁前,但它说EF5已安装(这是当我安装它通过NuGetmanager早期的没有指定 -Include $ p $租赁前。

Some Research has said that it has to do with EF5 not enabling prereleases. I ran Install-Package EntityFramework -IncludePrerelease but it said EF5 was already installed (which it was when I installed it through the NuGetmanager earlier without specifying -IncludePrerelease.

有谁知道我必须做的,使迁移为我的项目?

Does anyone know what I have to do to enable migrations for my project?

推荐答案

我刚刚有同样的问题,发现你的问题,同时寻找解决的办法。

I just had the same problem and found your question while searching for a solution.

我得到了它的工作。这个问题,对我来说,是我最初的目标在.NET 4.0框架,当我通过的NuGet加入EF 5。更改目标框架,然后通过重新安装的NuGet EF 5,固定它。它也有可能(见注释),只是通过重新安装的NuGet EF 5是你的解决方案。

I got it working. The problem, for me, was that I initially targeted the .NET 4.0 framework when I added the EF 5 via NuGet. Changing the target framework and then reinstalling EF 5 via NuGet, fixed it. It's also possible (see comments) that just reinstalling EF 5 via NuGet is the solution for you.

我在App.config文件中的以下行,注意版本= 4.4.0.0:

I had the following line in the App.config file, notice Version=4.4.0.0:

<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
</configuration>

所以我所做的就是目标框架设置为4.5的解决方案配置内部和设置支持运行时4.5太(应用程序配置里面)。

So what I did was set the target framework to 4.5 inside the solution configuration and set the supported runtime to 4.5 too (inside the app config).

老:

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>

新:

  <startup>
    <supportedRuntime version="v4.5" sku=".NETFramework,Version=v4.5" />
  </startup>

这改变后,我通过删除的NuGet 5.0 EF并重新添加它。它给了我下面的configSection作为结果,注意版本5.0.0.0 =

After that change, I removed EF 5.0 via NuGet and added it again. It gave me the following configSection as result, notice Version=5.0.0.0:

<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
</configuration>

这是更改后,它的工作。

After that change, it worked.

这篇关于“启用的迁移”升级到.NET 4.5和EF 5失败后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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