System. Data. entity not referenced when using Entity Framework (the type 'System. Data. Objects. Da

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.