“启用的迁移”升级到.NET 4.5和EF 5失败后,

编程入门 行业动态 更新时间:2024-10-16 00:20:16
本文介绍了“启用的迁移”升级到.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失败后,

本文发布于:2023-11-16 23:03:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1607861.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:升级到   NET   EF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!