Entity Framework is an ORM framework. ORM stands for Object Relational Mapping. Object Relational Mapping automatically creates classes based on database tables, and vice-versa is also true, it means it can generate necessary SQL to create database tables based on classes. .Net applications may connect with any kind of data sources like flat files, XML data, or relational databases. Irrespective
If you have two tables showing on the left side and you want to create a new table using that data then you have to follow the following steps in ADO.NET:
1. We need to create Department and Employee classes.
2. Write ADO.NET code to retrieve data from the database.
3. Once the database is created, we need to create department and employee objects and populate them with the data.
Note: Entity Framework can do all the above automatically if we provide it with the database schema.
Entity Framework provides us a class called DbContext which is our gateway to our database. A DbConext can have one or more DbSet and this DbSet represent a table in our database. We use LINQ query to query this DbSet and Entity Framework translates these LINQ queries to SQL queries at runtime.
Three Important Entity Framework Approaches are:
1. Database First Approach.
- We design our tables.
- Entity Framework generates domain classes.
2. Code First Approach.
- We create our domain classes.
- Entity Framework generates database tables.
3. Model First Approach.
- We create a UML diagram.
- Entity Framework generates domain classes and databases.
No comments:
Post a Comment