Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange compilation error in Entity Framework and MVC application

I've just created a new MVC 2 application that references both an entity model library and a services library, and all compiles fine without running the app, but when I try running it, I get the following runtime error"

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'.

I have double checked umteen times (e.g. Umpteen*n) and the cited assembly is refenced in all three projects. If it wasn't, WTF would I not get a build error?

like image 951
ProfK Avatar asked Dec 02 '22 05:12

ProfK


1 Answers

For ASP.NET MVC 4 (.NET4.5) change from

<system.web>
     <compilation debug="true" targetFramework="4.0" />
 ...

To

 <system.web>
   <compilation debug="true" targetFramework="4.0" >
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
      </assemblies>
    </compilation>
like image 120
İbrahim Özbölük Avatar answered Dec 04 '22 02:12

İbrahim Özbölük