
This article gives the introduction about Entity Framework core, which is a modern, lightweight, open-source Object–Relational Mapper (ORM) for .NET. It lets you work with a database using C# objects instead of writing rawSQL. It is designed to work with .NET Core and .NET Framework applications and provides an Object-Relational Mapper (ORM) that enables .NET developers to work with a database using .NET objects.
ORM stands for Object Relational Mapping. It allows developers to convert data between OOPS and Relational database(such as sqlserver,mysql,oracle) ORM allows developers to work with data in terms of objects rather than tables and columns.It means ORM automatically creates classes based on database tables and vice versa. ORM framework takes repsponsibility of CRUD operations such as opening connection,executing command,handling transaction,closing connection.It simply does all the data access related things.
There are three kinds of entity framework approaches.
Here data model classes is created first, entity framework core created database schema based on model
For eg:-
public Class Customer
{
public int Customerid{get;set;}
public string CustomerName{get;set;}
public string Address{get;set;}
public string City{get;set;}
public string Country{get;set;}
}
In database first approach, here existing database is available.EF core will generate model class based on table in database.In this approach, application code will not have control on database.
EF Core supports various database providers such as
| EF 6 | EF Core |
|---|---|
| It was released in 2008 with .Net Framework 3.5 | It was released in June 2016 with .Net Core 1.0 |
| Windows only | Windows , Linux, osx |
| Works on .Net framework 3.5+ | Works on .Net framework 4.5+ and .Net core |
| Less Optimized | Optimized for performance |
| Old LINQ support | Improved LINQ support |
| Here also Eager/Explicit/Lazy supported but traditional way. | Eager/Explicit/Lazy : works with better control |
| Traditional Migration | Fluent Migration |