Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

References for DBContext, DBSet<> in Entity Framework

Tags:

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 to create the model first. Inside the tutorial DBContext and DBSet<> is specified. Could some tell what is the reference to be used in order to access this class.

I have used the following references however nothing happens for DBContext and DBSet<>

  • System.Data.Entity
  • System.Data.Entity.Design
like image 677
manu Avatar asked Feb 04 '11 13:02

manu


People also ask

What is DbSet <>?

A DbSet represents the collection of all entities in the context, or that can be queried from the database, of a given type. DbSet objects are created from a DbContext using the DbContext.

Is DbSet part of DbContext?

The DbSet class represents an entity set that can be used for create, read, update, and delete operations. The context class (derived from DbContext ) must include the DbSet type properties for the entities which map to database tables and views.

What is the difference between DbSet and DbContext?

Intuitively, a DbContext corresponds to your database (or a collection of tables and views in your database) whereas a DbSet corresponds to a table or view in your database.

What is DbSet in Entity Framework Core?

In Entity Framework Core, the DbSet represents the set of entities. In a database, a group of similar entities is called an Entity Set. The DbSet enables the user to perform various operations like add, remove, update, etc. on the entity set.


2 Answers

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.

like image 179
Feckmore Avatar answered Oct 08 '22 13:10

Feckmore


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).

like image 30
Ladislav Mrnka Avatar answered Oct 08 '22 13:10

Ladislav Mrnka