Introduction to Entity Framework Core (EF Core)
This is the first article of the Entity Framework Core tutorial series. In this series, you will learn from scratch what Entity Framework Core is and how it can be installed and used in your application to create databases and tables and insert, read, update and delete data from them.
What is Entity Framework Core?
Entity Framework Core (EF Core) is an open-source ORM(Object Relational Mapper) framework for .NET applications. An ORM is a framework connecting objects in your application with the tables and fields in a database where the application stores data. Entity Framework Core enables .NET developers to work with a database using .NET objects. It is extensible, lightweight, and supports cross-platform development as it is a part of Microsoft’s .NET Core framework. Entity Framework can be considered the next version of ADO.NET that provides an easy mechanism for creating and modifying databases and tables and for storing, retrieving, and deleting data from them.
EF Core supports many database engines. You can check Microsoft’s site to know more about the supported database engines
Some advantages of Entity Framework Core
Entity Framework Core makes a developer's life easy as it helps to easily create and maintain a data-oriented application with less code. A developer doesn’t need to learn and write SQL queries. Repetitive tasks like CRUD (create, read, update and delete) operations can be done with ease without writing a single line of SQL script. This makes the development faster.
Entity framework can generate a database from your models. It can also generate models from the database. Whatever approach you use (database first approach or code-first approach), it is easier than the traditional approach of manually creating the database and models. Thus Entity Framework core reduces development time and development cost.
In Entity Framework Core, you can use Language Integrated Queries (LINQ) to query the underlying database. LINQ queries are less vulnerable to SQL injection attacks.
Entity Framework Core can run in Windows, Linux, and Mac as it is a part of .NET, the cross-platform development framework from Microsoft.
Next, we will install Entity Framework in a Razor Page application