Entity Framework Core series of tutorials
translated from:
https://www.entityframeworktutorial.net/efcore/entity-framework-core.aspx
Entity Framework Core Introduction
Brief introduction
Entity Framework Core (EF Core) is a lightweight, scalable, open-source and cross-platform version of the popular Entity Framework data access technology.
EF Core may be used as object relational mapper (O / RM), so that developers can use .NET .NET object to handle the database, so data will not have to prepare most of the access code.
EF Core is an object / relational mapping (O / RM) framework. It is an enhancement to ADO.NET, which provides an automatic mechanism for developers to access and store data in the database.
EF Core in use with .NET Core applications. However, it can also be used with applications based on standard .NET 4.5+ Framework.
The following figure shows the EF Core supported application type, .NET Framework and operating systems:
EF Core Version History
EF Core 3.1 is the current version, is long-term support version, suitable for project development.
Release | Target framework | Support Deadline |
---|---|---|
EF Core 3.1 | NET Standard 2.0 | December 3, 2022 (LTS) |
EF Core 3.0 | .NET Standard 2.1 | 2020 March 3 |
EF Core 2.2 | .NET Standard 2.0 | Expiration Date: December 23, 2019 |
EF Core 2.1 | .NET Standard 2.0 | 021 On August 21 (LTS) |
EF Core 2.0 | .NET Standard 2.0 | Expiration Date: October 1, 2018 |
EF Core 1.1 | .NET Standard 1.3 | Expiration Date: June 27, 2019 |
EF Core 1.0 | .NET Standard 1.3 | Expiration Date: June 27, 2019 |
EF Core GitHub Source: https://github.com/aspnet/EntityFrameworkCore
EF Core Roadmap: docs.microsoft.com/zh-cn/ef/core/what-is-new/roadmap
EF's Core AND DELINQUENCY: HTTPS: // GitHub .com / ASPNET / EntityFrameworkCore / AND DELINQUENCY
EF Core official document: https://docs.microsoft.com/ef/core
Why EF Core
- productive forces
- It supports many databases
- You can use Linq
- Focus on areas (Domain), rather than the database
EF Core development methods
EF Core development supports two methods: 1) Code-First (priority codes); 2) Database-First (priority database). EF Core mainly for Code-First approach provides little support for Database-First approach, because from the beginning EF Core 2.0 does not support DB visual model designer or wizards.
In Code-First (method, EF Core API based on conventions and configure your domain model code provided with a migration to create the database and tables. This method is driven design (DDD) is useful in the field.
In Database-First approach, EF Core API commands used to create EF Core domain model and database context (the DbContext) classes based on an existing database. Because it does not support the Visual Designer or wizard, and therefore support the EF Core is limited.
EF Core vs EF 6
EF Core is mainly used for .NET Core applications based on the new and improved version of the Entity Framework version, EF Core also supports the .NET Framework applications.
Entity Framework 6 (EF6) is designed specifically for the .NET Framework object-relational mapper, but supports .NET Core.
EF and EF Core continues to support the same features and concepts of the following 6:
- DbContext & DbSet
- Data Model
- Querying using Linq-to-Entities
- Change Tracking
- SaveChanges
- Migrations
EF Core will gradually include most of the features EF 6. However, EF Core 2.0 does not support some features of EF 6, for example:
- Graphics EDMX / Model Visualization
- Entity Data Model Wizard (for DB-First Method)
- ObjectContext API
- Querying using Entity SQL.
- Use Entity SQLL inquiry
- Automatic migration
- Inheritance: Each type of a table (TPT)
- Inheritance: Each concrete class table (TPC)
- To-many, connectionless entity
- Split entities
- Spatial Data (Spatial Data)
- Lazy loading associated data
- DbContext map using stored procedures to perform operations CUD
- Data Seed (Seed data)
- Automatic migration (Automatic migration)
EF Core includes the following new features EF 6.x is not supported:
- Relations configuration is more convenient
- CRUD batch operations
- In-memory provider provided for the test program
- Support IoC (Inversion of Control)
- Unique key constraint
- Projection property
- Alternate keys (spare key)
- Global Query filter
- Field Mapping
- DbContext connection pool
- Provide a better model for physical disconnection processing of FIG.
Here to learn more about the difference EF Core 6 and EF.
EF Core Database Providers
EF Core using Provider (provider) model program to access many different databases. We need to add the appropriate Database Provider NuGet package in an application to use a different database.
The following table lists the EF Core database provider and NuGet package.
database | NuGet package |
---|---|
SQL Server | Microsoft.EntityFrameworkCore.SqlServer |
MySQL | MySql.Data.EntityFrameworkCore |
PostgreSQL | Microsoft.EntityFrameworkCore.SqlServer |
SQLite | Microsoft.EntityFrameworkCore.SQLite |
SQL Compact | EntityFrameworkCore.SqlServerCompact40 |
In-memory | Microsoft.EntityFrameworkCore.InMemory |
Other Database Provider Reference:
https://docs.microsoft.com/zh-cn/ef/core/providers/index?tabs=dotnet-core-cli
The next chapter, we will learn to install EF Core.