Today, I just learned the razor of MVC and used the Entity Framework together. The following error is returned:
Cs0012: the type'System. Data. Objects. dataclasses. entityobject' IsDefinedInAn assembly thatIsNot referenced. You must add a reference to assembly'System. Data. entity, version = 4.0.0.0, culture = neutral, publickeytoken = b77a5c561934e089'.
I started getting a compilation error telling with a message telling me "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 '". this really confused me since the solution built fine but the error only occurred at run time.
obviusly, it is all about adding a reference to system. Data. entity to my web project right? I checked and it is already there. removed it re-added it. Checked for the correct version but still it doesn' t like it! Why?
this came about when I used an existing models project from a different solution in a brand new MVC 2 web application. so I checked the differences between the working solution and the new solution. both had the same reference in the web project so what's wrong?
Solution:
<Compilation DEBUG = " True " Targetframework = " 4.0 " > <Assemblies> <add Assembly = " System. Web. Export actions, version = 4.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 = 2.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35 " /> <Add Assembly = " System. Data. entity, version = 4.0.0.0, culture = neutral, publickeytoken = b77a5c561934e089 " /> </Assemblies> </compilation>
Add the reference system. Data. entity to Web. config.
<Add Assembly ="System. Data. entity, version = 4.0.0.0, culture = neutral, publickeytoken = b77a5c561934e089"/>
http://www.britishdeveloper.co.uk/2010/07/systemdataentity-not-referenced-when.html? Showcomment = 1346688745974 # c8856184184545990837