@Human80IQ The DbContextis the way that Entity understands what tables you are using in your database, for example:
[Table("tuTabla")]
public class TablaEntity
{
[Key, Column(Order = 0)]
[Required]
public int ID { get; set; }
[Required(ErrorMessage = "Debe Ingresar Un Nombre.")]
[StringLength(255, ErrorMessage = "{0} la longitud debe estar entre {2} y {1}.", MinimumLength = 4)]
[Display(Name = "Nombre")]
public string NOMBRE { get; set; }
[Required(ErrorMessage = "Debe Ingresar Un Valor.")]
[Range(1, 100000)]
[Display(Name = "Valor")]
public int VALOR { get; set; }
This is an example of a model for Entity, that is to say what a table will be, when you are in a controller, you dbContextwill be in charge of invoking the data through the model, treating them in the controller and displaying them in your view of course if you use MVC.
DbContextis the primary class responsible for interacting with the database.
It is responsible for the following activities:
Query : Converts queries LINQ-to-Entitiesto queries SQLand sends them to the database.
Change Tracking - Tracks changes that occurred to entities after querying from the database.
Persistent Data – Performs Insert, Update, and Delete operations on the database, based on the states of the entity.
Caching - Provides first level caching by default. Stores the entities that have been retrieved during the lifetime of a context class.
Manage Relationships: Manage relationships using CSDL, MSLand SSDLin the Db-Firstor approach Model-First, and using fluent API configurations in the approachCode-First.
Object materialization: Converts raw data from the database into entity objects.
@Human80IQ The
DbContext
is the way that Entity understands what tables you are using in your database, for example:This is an example of a model for Entity, that is to say what a table will be, when you are in a controller, you
dbContext
will be in charge of invoking the data through the model, treating them in the controller and displaying them in your view of course if you useMVC
.I hope it helps you.
DbContext
is the primary class responsible for interacting with the database.It is responsible for the following activities:
Query : Converts queries
LINQ-to-Entities
to queriesSQL
and sends them to the database.Change Tracking - Tracks changes that occurred to entities after querying from the database.
Persistent Data – Performs Insert, Update, and Delete operations on the database, based on the states of the entity.
Caching - Provides first level caching by default. Stores the entities that have been retrieved during the lifetime of a context class.
Manage Relationships: Manage relationships using
CSDL
,MSL
andSSDL
in theDb-First
or approachModel-First
, and using fluent API configurations in the approachCode-First.
Object materialization: Converts raw data from the database into entity objects.