Introduction to EF Core
Entity Framework (EF) Core is a lightweight, extensible, open source and cross-platform version of the popular Entity Framework data access technology, EF Core is a modern object database mapper for . It supports LINQ queries, change tracking, updates, and schema migrations.EF Core works with SQL Server, Azure SQL Database, SQLite, Azure Cosmos DB, MySQL, PostgreSQL, and other databases through the Provider Plugin API (officially from Microsoft).
Entity Framework Plus
Entity Framework Plus is an open source, free (MIT License), powerful Entity Framework (EF) and Entity Framework Core (EF Core) extension library designed to enhance the performance of Entity Framework and overcome its limitations. By providing a series of practical features , such as batch operations , query caching , query latency , LINQ dynamics , audit trails , etc., to make database development using Entity Framework has become more efficient and flexible .
Project Functional Features
followingEntity Framework Plus
Some of the key features and functions of the project:
-
batch operation: Supports batch insert, update, delete, and merge operations that can process multiple records in a single database round-trip without loading entities into memory, resulting in significant performance improvements.
-
query cache: Provides a query caching feature that allows query results to be cached in memory to reduce repetitive queries to the database and improve application response time.
-
latency of inquiry: Allows the execution of queries to be delayed so that they can be executed in conjunction with other functionality (such as query caching and query future) if needed.
-
Query Filtering: Supports the application of filters at the global, instance, or query level so that they are automatically applied when data is retrieved.
-
Enquire about the future: Allows multiple queries to be merged into a single database round-trip, thus reducing the number of database round-trips and improving performance.
-
Query Inclusion Optimization: The behavior of the Include method has been improved to allow filters to be applied when loading associated entities, thus optimizing the generated SQL statement.
-
Audit trail: Provides audit trail functionality that allows changes to entities to be automatically tracked and audit information to be saved to the database.
-
Support for multiple versions of Entity Framework:
EntityFramework-Plus
Entity Framework 5 (EF5), Entity Framework 6 (EF6) and Entity Framework Core (EF Core) are supported. -
Easy to integrate: The NuGet package manager makes it easy to put the
EntityFramework-Plus
Integrate into an existing Entity Framework or Entity Framework Core project.
Project NuGet Package Installation
Search in the NuGet Package Manager:package for installation.
batch deletion
If hundreds or thousands of entities need to be deleted, deletion using Entity Framework Core can be very slow. Entities are first loaded into the context before they are deleted, which is very bad for performance, and then they are deleted one by one, which makes the deletion operation worse.
var ctx = new EntitiesContext();
// Delete all users inactive for 2 years
var date = (-2);
(x => < date)
.Delete();
// Delete using BatchSize
var date = (-2);
(x => < date)
.Delete(x => = 1000);
batch update
If you need to update hundreds or thousands of entities with the same expression, updating with Entity Framework Core can be very slow. Entities are first loaded into the context before they are updated, which is very bad for performance, and then, they are updated one after the other, which makes the update operation worse.
var ctx = new EntitiesContext();
// Renewal of 2 years of inactivity for all users
var date = (-2);
(x => < date)
.Update(x => new User() { IsSoftDeleted = 1 });
Query Filter
Global Filter
// CREATE global filter
<Customer>(x => (c => ));
var ctx = new EntityContext();
// TIP: Add this line in EntitiesContext constructor instead
(ctx);
// SELECT * FROM Customer WHERE IsActive = true
var customer = ();
Instance Filtering
var ctx = new EntityContext();
// CREATE filter
<Customer>(x => (c => ));
// SELECT * FROM Customer WHERE IsActive = true
var customer = ();
Query Filter
var ctx = new EntityContext();
// CREATE filter disabled
<Customer>(, x => (c => ), false);
// SELECT * FROM Customer WHERE IsActive = true
var customer = ().ToList();
Project source code address
More useful features and characteristics of the project welcome to the project open source address to view 👀, do not forget to give the project a Star support 💖.
- Open Source Address:/zzzprojects/EntityFramework-Plus
- Online documentation:
A selection of great projects and frameworks
This project has been included in the C#/.NET/.NET Core Excellent Projects and Frameworks Selection, focusing on the excellent projects and frameworks selection can let you keep abreast of the latest developments and best practices in the field of C#, .NET and .NET Core, and improve the efficiency and quality of development work. The pit has been dug, you are welcome to submit PR recommendations or self-recommendation (so that excellent projects and frameworks are not buried 🤞).
- GitHub Open Source Address: /YSGStudyHards/DotNetGuide/blob/main/docs/DotNet/
- Gitee open source address:/ysgdaydayup/DotNetGuide/blob/main/docs/DotNet/