Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 363
Y Haber Avatar asked Mar 27 '12 19:03

Y Haber


2 Answers

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.

like image 133
Y Haber Avatar answered Oct 09 '22 04:10

Y Haber


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.

like image 23
oruchreis Avatar answered Oct 09 '22 04:10

oruchreis