1

I have a website using ASP.Net Webforms and Entity Framework and during compilation VS2010 tells me the following error:

error 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=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

The problem is that the reference is properly configured in web.config

The properties page of the project says that the Framework version used in the project is v3.5, which is correct.

Any help will be appreciated.

This is the assemblies section in my web.config

<assemblies>
    <add assembly="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>. 
  • Does the reference appear under Project/References? – jrummell Oct 26 '11 at 16:36
  • 1
    Add the reference to your project file. Right click the project and Add References. – Scott Wylie Oct 26 '11 at 16:37
  • Are u using EF directly from you UI? check this one which also applies to webforms http://stackoverflow.com/questions/7474267/mvc3-and-entity-framework/7474357#7474357 – Davide Piras Oct 26 '11 at 16:54
  • The reference shows up everywhere on the project where it should. It's definitely some environemnt/framework issue. –  Oct 26 '11 at 23:04
  • I have installed VS2010 in another PC and have to switch back and forth the version of the framework I'm using. Finally I set the version to 3.5 and then the project compiles without errors or warnings. Any clues? –  Oct 26 '11 at 23:14

2 Answers2

2

can you show your web.config references? My guess is that either the version # is off, or that perhaps the EF assmebly is not installed in the GAC.

  1. Check that the exact version you want is referenced in web.config
  2. If the assembly is in your bin directory, right click on it in Windows Explorer and choose 'Properties' and find the version. Make sure it matches web.config.
  3. If you are relying on the GAC, open c:\windows\assembly in Windows Explorer to see if that exact version of the EF assembly is there
Mike Marshall
  • 7,788
  • 4
  • 39
  • 63
  • Yes I'm relying on GAC and I can't find the dll in assembly folder. How can I update the GAC? –  Oct 26 '11 at 22:48
  • I'm unfamiliar with the EF install - but according to this (http://stackoverflow.com/questions/2079894/installing-entity-framework) version 3.5 comes with .NET Framework 3.5 SP1 (which can be found here: http://www.microsoft.com/download/en/details.aspx?id=22) – Mike Marshall Oct 27 '11 at 18:44
0

The only time I get that is when the DLL is missing from a project, and it may not just be the root project. If you have another project that uses the EntityObject class, and its missing there, you'll get the error.

Brian Mains
  • 50,520
  • 35
  • 148
  • 257