Blog from Saravanan Arumugam

Let us talk about Technologies

Tag Archives: Asp.Net

The type ‘System.Data.Objects.DataClasses.EntityObject’ is defined in an assembly that is not referenced


I am working on an MVC 3 application where I use an Entity Object as the model to the View. I was getting the following error in the browser.

Exception

Compiler Error Message: 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’.

Solution:

It was interesting that the MVC project by default has the reference to System.Data.Entity namespace. But still the issue was presented. I finally figured out the clue from another word press blog. I had to add the assembly entry in the Web.config to resolve the issue.

  <assemblies>

    <add assembly=System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35 />

    <add assembly=System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35 />

    <add assembly=System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35 />

    <add assembly=System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35 />

    <add assembly=System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35 />

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

  </assemblies>

Note that the complete assembly name is presented in the exception message itself.

Advertisements