Here you will learn about the basic CRUD workflow using Entity Framework.
The following figure illustrates the basic workflow.
Let’s understand the above EF workflow:
- First of all, you need to define your model. Defining the model includes defining your domain classes, context class derived from DbContext, and configurations (if any). EF will perform CRUD operations based on your model.
- To insert data, add a domain object to a context and call the
SaveChanges()
method. EF API will build an appropriate INSERT command and execute it to the database. - To read data, execute the LINQ-to-Entities query in your preferred language (C#/VB.NET). EF API will convert this query into SQL query for the underlying relational database and execute it. The result will be transformed into domain (entity) objects and displayed on the UI.
- To edit or delete data, update or remove entity objects from a context and call the
SaveChanges()
method. EF API will build the appropriate UPDATE or DELETE command and execute it to the database.
Let’s see how EF works in the next chapter.
No comments:
Post a Comment