How to get enums working in mvc4 with Entity Framework 5 Beta 2?

假如想象 提交于 2019-12-10 14:39:08

问题


I used Nuget to update to Entity Framework 5.0.0-beta2 in my MVC3 -> MVC4 project.

I'm trying to get the enums to work, and each migration I add just ignores the enum fields.

I found this in the web.config:

  <configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

How do I get this reference updated to EF5?

Is that what I need to get enums working?


回答1:


I found the answer to this on Julie Lerman's blog.

The solution is to remove the EF5 Nuget package, update the app to target .net 4.5 and then add the Nuget for EF5 Beta back in. Apparently when you are targeting .net 4.0 the Nuget package will add EF4.4 instead of 5.




回答2:


Check the Project Target which must target .NET 4.5 not .NET 4.0. Even if you are in VS 11, EF 5 needs .NET 4.5.



来源:https://stackoverflow.com/questions/9896692/how-to-get-enums-working-in-mvc4-with-entity-framework-5-beta-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!