C# – MVC4: Compilation Error The type ‘System.Data.Objects.DataClasses.EntityObject’ is defined in an assembly that is not referenced

asp.netasp.net-mvc-3asp.net-mvc-4cnet

The following line of code is throwing the following error when i try to load the page:

CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

@Html.DropDownListFor(model => model.Courses.Id, Model.CourseList)

In MVC3, I remember fixing this easily by adding the following line in the web.config file:

<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

However in MVC4 you cannot use the tag anymore, so I'm not sure how I can resolve it. Any help is greatly appreciated.

Best Answer

nvm, I was wrong you have to open up the tag and add the tag yourself.

Solution:

<compilation debug="true" targetFramework="4.0">
  <assemblies>
      <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    </assemblies>
  </compilation>