GomuGomuZoro
GomuGomuZoro

Reputation: 313

MVC4: Compilation Error The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced

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.

Upvotes: 3

Views: 8152

Answers (4)

dellyjm
dellyjm

Reputation: 426

Load User Profile in the Application Pool Advance Settings.

This approach solved this for me.

Upvotes: 0

Nibedita Panda
Nibedita Panda

Reputation: 21

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>

Upvotes: 1

GomuGomuZoro
GomuGomuZoro

Reputation: 313

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>

Upvotes: 8

olif
olif

Reputation: 3299

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

Upvotes: 1

Related Questions