none
Adding reference to System.Data.Entity doesn't help RRS feed

  • Question

  • I'm getting the error "The type 'System.Data.Entity.DbContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'EntityFramework, Version=5.0.0.0, blahblahblah' So I've tried adding a reference to System.Data.Entity in add references, and I've also tried adding the strong name reference inside of the assemblies tag which is inside of compilation tag in web.config. I added the tag <add assembly="EntityFramework, Version=5.0.0.0, blahblahblah" /> where the part inside the quotes didn't have the blahblahblah but had the entire string copied from the error message and pasted into the quotes within the add tag. Neither of these methods for adding is getting the compiler to recognize that the assembly is being referenced. Any help? If you can ansewr, I will mark, I'm an expert marksman. Thanks, James
    • Moved by Amanda Zhu Tuesday, May 28, 2013 2:22 AM move to a more appropriate forum
    Friday, May 24, 2013 4:00 PM

All replies

  • It took me awhile the 1st time I saw this message but finally figured it out a couple of years ago.  Sart by adding the following library reference in the Project - Add Reference - Net tab

    PresentationFramework


    jdweng

    Friday, May 24, 2013 4:14 PM
  • PresentationFramework is already in there. I'm not the one who added it, but it's there (this is a huge project with many people working on it). Gives this error anyways.
    Friday, May 24, 2013 5:28 PM
  • Debug the code by creating a new project and just put the minimum number of libraries require to remove the errors.  I often find by using the Edit - Find - Symbol (it vaires where Symbol is located depedning on VS version).  Choose all components.  This will help you resolve the problem.  You may have conflicts between libraries and then you will need to include the namespace to resolve the conflicts.

    jdweng

    Friday, May 24, 2013 5:47 PM
  • I added a fresh new project to the solution, put only a reference to the namespace that the entities class inheriting from DBContext is in, and added the reference, to no avail. I tried strong name reference in web.config and just adding the reference through Add References. I even tried excluding "using" for the DBContext inherited class namespace, and specifying that namespace when I declare the instance of the context class, it still doesn't work.
    Friday, May 24, 2013 8:31 PM
  • Can you post the test code so I can take a look.

    jdweng

    Friday, May 24, 2013 9:41 PM
  • This solution is way too large to post the test code. There's a lot of dependencies between multiple solutions, too, which makes it even larger. Plus, the code is not to be distributed. I can give you details if you ask, but I can't post the code.
    Tuesday, May 28, 2013 1:04 PM
  • Did you add a reference to the EntityFramework.dll?
    Tuesday, May 28, 2013 1:47 PM
  • Yes I did. Now, if I remove the regular reference, and I put in the strong name reference like suggested in the original error, it gives that error that you always see that says (are you missing an assembly reference?) in it. The edmx resides in another project in the solution, and I've tried putting the strong reference in the app.config there, and also tried putting it in the web.config in the project where the error is occuring (with the context instance being created) I put the strong name assembly reference with the PublicKeyToken and all that stuff inside the following nested tags: <system.,web> <compilation> <assemblies> using the <add assembly .... . > tag just as such a reference is supposed to be added. Apparently it's not recognizing that my strong name reference is there, because if it was it wouldn't need the regular reference in "References"? Is this true?
    Tuesday, May 28, 2013 2:09 PM