What is Entity Framework Core?

I've wanted to make a course on EF for some time now, since starting from the .NET 6 versions 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 created by Microsoft that allows us to access databases, mainly relational ones, in a very simple way.

 

The big advantage of Entity Framework Core is its simplicity and friendliness, since it lets us use code instead of SQL directly. In addition, it is compatible with the LINQ library, although you should be careful doing crazy things with LINQ because that's where you might run into performance issues.

 

Of course, as a library that is widely accepted in the market, it has very powerful features such as support for concurrency, support for transactions, caching, or, as I mentioned before, the ability to use code instead of SQL. It also allows you to use entities to represent tables.

 

Finally, it allows us to choose the type of structure or development approach we want, 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 was always very reluctant to use Entity Framework due to the performance issues it had when running queries. But since .NET 6, it has improved a lot, and in this latest version of .NET 7, it's practically on the same level as Dapper, which was the ORM I always used.

 

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

 

Nowadays, I recommend using Entity Framework Core, maybe not always, but in 99% of cases. Except for very complex queries, the "default version" of Entity Framework works just fine, 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, while Entity Framework Core is tied to .NET or .NET Core. Also, Entity Framework Core is lighter and receives the latest updates.

 

Microsoft's naming isn't the best and is quite confusing. Here you have a post where I break it down.

 

2 - Code First vs Database First

When we talk about creating new projects that require a database, we always have in mind if we should use a "Code First" or "Database First" process.

 

We will go deeper into these processes later, but we can summarize the following:

 

2.1 - What is Code First?

Code First is the process where the developer writes the classes that are going to be used as entities, and Entity Framework is responsible for creating the tables based on those classes.

 

2.2 - What is Database First?

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

 

2.3 - What is Model First?

Alternatively, with Entity Framework and Visual Studio, we can use the Model First process, which involves going to the Visual Studio designer and creating the entities as well as their relationships right in the designer.

 

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

Uso del bloqueador de anuncios adblock

Hola!

Primero de todo bienvenido a la web de NetMentor donde podrás aprender programación en C# y .NET desde un nivel de principiante hasta más avanzado.


Yo entiendo que utilices un bloqueador de anuncios como AdBlock, Ublock o el propio navegador Brave. Pero te tengo que pedir por favor que desactives el bloqueador para esta web.


Intento personalmente no poner mucha publicidad, la justa para pagar el servidor y por supuesto que no sea intrusiva; Si pese a ello piensas que es intrusiva siempre me puedes escribir por privado o por Twitter a @NetMentorTW.


Si ya lo has desactivado, por favor recarga la página.


Un saludo y muchas gracias por tu colaboración

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

Buy me a coffee Invitame a un café