简体   繁体   中英

DBSet<entity> class not found (Entity Framework loading wrong DLL?)

In my Visual Studio 2015 project I have a declaration

public DBSet<Page> Pages { get; set; }

which gives me the error

The type or namespace name 'DBSet' could not be found (are you missing a using directive or an assembly reference?)

.. which shouldn't be happening because I have ...

using System.Data.Entity;

at the start of the file.

DBSet class was introduced in Entity Framework 5. I 'm using V 6.1.32.

I have a feeling this is related to my other problem: ModelConfiguration does not exist in the namespace 'System.Data.Entity'

It appears that in spite of having EF 6 installed somehow a DLL of EF 4 is being used. If I try to manually add a reference to system.data.entity (obviously not a good idea) 4.0.0.0 is the version number that is shown.

I tried the following sequence (as was suggested in a comment in my other question)...

  1. Uninstall EF using NuGet.
  2. Delete bin folder
  3. Reinstall EF using NuGet

I even tried uninstalling and reinstalling VS 2015.

Is there another folder in my project or my computer that contains DLLs that may be used by VS?

When I installed SQL Server Management Studio 2014, VS 2010 was also automatically installed. Could this be interfering with VS 2015?

I'm getting quite desperate as this is stopping me from continuing my MVC project.

Check your casing. I believe it is: DbSet<T> . So, in this case:

public DbSet<Page> Pages { get; set; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM