3
votes

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.

4
Project -> references -> right-click -> add referenceCasey

4 Answers

6
votes

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>
1
votes

Add a reference to Entity Framework in your MVC project. That should fix the issue.

0
votes

This solution has worked for me:

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