References for DBContext, DBSet<> in Entity Framework

前端 未结 5 1851
长发绾君心
长发绾君心 2021-02-12 11:11

I am trying to use ADO.Net Codefirst feature of latest Entity Framework 4.0. As part of that I have installed Entity Framework CTP 4 from Microsft and using Scott\'s tutorial t

相关标签:
5条回答
  • 2021-02-12 11:23

    Use "DbContext" vs "DBContext", and "DbSet" vs "DBSet". The case sensitivity is the issue.

    0 讨论(0)
  • 2021-02-12 11:28

    Use CTP5 instead it is newer version with some changes in API. You have to add reference to EntityFramework.dll which is installed in CTP directory - default is: c:\Program Files\Microsoft ADO.NET Entity Framework Feature CTP5\Binaries\EntityFramework.dll for 32bit system. On 64bit system it will be placed in Program Files (x86).

    0 讨论(0)
  • 2021-02-12 11:30

    You can use the Library Package Manager if you have it (it installs automatically with MVC 3.0).

    From within your project in Visual Studio 2010, go to

    Tools > Library Package Manager > Package Manager Console
    

    From within your project in Visual Studio 2013, go to

    Tools > NuGet Package Manager > Package Manager Console
    

    In the console, after the PM> prompt, type

    install-package entityframework
    

    This will install the package and add the EntityFramework reference to your project.

    0 讨论(0)
  • 2021-02-12 11:40

    The blogpost mentions the assembly:

    The DbContext and DbSet classes used above are provided as part of the EF4 Code-First library. You’ll need to add a reference to the System.Data.Entity.CTP assembly that is installed into the \Program Files\Microsoft ADO.NET Entity Framework Feature CTP4\Binaries directory to reference these classes. You’ll also want to add a “using System.Data.Entity” namespace statement at the top of your “NerdDinners” class file.

    However I do believe the new CTP5 includes some changes to codefirst, so I would suggest to take a look at that one instead.

    0 讨论(0)
  • 2021-02-12 11:43

    To add EF to your project use the Package Manager Console and issue the command:

    Install-Package EntityFramework
    

    You shouldn't link directly to the DLLs' installed location as mentioned in another answer.

    0 讨论(0)
提交回复
热议问题