Introduction to Entity Framework

What is Entity Framework (EF)?

If our application needs a data operation, we need to write our own code(as a framework) using a few Microsoft technologies such as SQLConnection, SQLCommand, and SQLDatareader. This also involves writing a complex Stored Procedure.

Entity Framework takes care of all of these, and we don't need to use complex code to manage our database.

Consider it something like this - you create classes (which are models), and you can translate (migrate) these classes to the tables using a few EF commands. It is that simple. However, you can also do it oppositely. You can migrate the database tables to the classes. Let us discuss this in our next section.

What is EF Work Flows?

There are three workflows in EF-

Code-First

As discussed before, in this workflow, we create domain classes and migrate these to database tables.

Database-First

In this workflow, we have database tables, and we shall migrate these tables to domain classes.

Model-First

In this approach, we will create diagrams using Visual designer, and we will migrate these to domain classes and database tables. I have never used it, and I am not comfortable explaining this approach.