What is Entity Framework Core?

I've been wanting to make a course on EF for a while now since from .NET 6 onwards, it has improved a lot. So let this post serve as an introduction to Entity Framework Core.

 

 

1- What is Entity Framework Core

Entity Framework Core is a library developed by Microsoft that allows us to access mainly relational databases in a very simple way. 

 

The big advantage of Entity Framework Core is that it is very simple and user-friendly since it lets us use code instead of direct SQL. It is also compatible with the LINQ library; however, be careful doing crazy things with LINQ as that's where you might encounter performance issues.

 

Of course, being such a widely adopted library, Entity Framework Core includes powerful features like concurrency support, transaction support, caching, and, as I mentioned before, using code instead of SQL. You also use entities as representations of tables.

 

Finally, it lets us choose the structure or development approach we want to take, whether through Code First or Database First; we'll see examples of both scenarios in the course.

 

1.1 - When to use Entity Framework Core

Personally, I've always been quite reluctant to use Entity Framework due to the performance issues it used to have when building queries. But since .NET 6, it has improved tremendously, and in the latest version, .NET 7, it's practically on the same level as Dapper, which was always my preferred ORM.

 

Here's a post about what an ORM and Dapper are

 

Nowadays, I do recommend using Entity Framework Core, maybe not always, but in 99% of cases, as except for very complex queries, the "default version" of Entity Framework does a good job, plus you can even pass literal SQL to it.

 

1.2 - Difference between Entity Framework and Entity Framework Core

 

The difference between Entity Framework and Entity Framework Core is simply that Entity Framework is tied to .NET Framework, whereas Entity Framework Core is tied to .NET or .NET Core. In addition, the latter is lighter and receives the most recent updates.

 

Microsoft's naming can be quite confusing and is not the best choice. Here's a post where I break it down.

 

2 - Code First vs Database First

When we're talking about creating new projects that need a database, we always have in mind whether we should use a "Code First" or a "Database First" approach.

 

We'll go into these processes in more depth later on, but here's a summary:

 

2.1 - What is Code First?

Code First is the process in which the developer writes the classes that will be used as entities, and Entity Framework takes care of creating the tables based on these classes.

 

2.2 - What is Database First?

Database First is the process where the database is created manually (via SQL) or already exists, and Entity Framework generates the entities based on that database.

 

2.3 - What is Model First?

Alternatively, with Entity Framework and Visual Studio, you can use the Model First process, which involves going to Visual Studio's designer and creating the entities and their relationships within the designer itself.

 

This post was translated from Spanish. You can see the original one here.
If there is any problem you can add a comment bellow or contact me in the website's contact form

© copyright 2025 NetMentor | Todos los derechos reservados | RSS Feed

Buy me a coffee Invitame a un café