{"id":15039456,"url":"https://github.com/zzzprojects/entityframework-plus","last_synced_at":"2025-05-14T21:02:19.983Z","repository":{"id":40523436,"uuid":"47288921","full_name":"zzzprojects/EntityFramework-Plus","owner":"zzzprojects","description":"Entity Framework Plus extends your DbContext with must-haves features: Include Filter, Auditing, Caching, Query Future, Batch Delete, Batch Update, and more","archived":false,"fork":false,"pushed_at":"2025-04-08T21:05:39.000Z","size":4383,"stargazers_count":2311,"open_issues_count":158,"forks_count":317,"subscribers_count":86,"default_branch":"master","last_synced_at":"2025-05-03T01:59:44.269Z","etag":null,"topics":["csharp","dotnet","ef6","efcore","entity-framework","entity-framework-core","entityframework"],"latest_commit_sha":null,"homepage":"https://entityframework-plus.net/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zzzprojects.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["zzzprojects"],"custom":["https://zzzprojects.com/contribute"]}},"created_at":"2015-12-02T21:12:52.000Z","updated_at":"2025-04-26T18:32:31.000Z","dependencies_parsed_at":"2023-02-14T02:16:21.028Z","dependency_job_id":"ca1abb8f-9b4c-4387-a4c0-b7befe78b73d","html_url":"https://github.com/zzzprojects/EntityFramework-Plus","commit_stats":{"total_commits":738,"total_committers":29,"mean_commits":"25.448275862068964","dds":0.6368563685636857,"last_synced_commit":"a80672f87473c174e7336c65eb758e9af77ae53c"},"previous_names":["zzzprojects/entity-framework-plus"],"tags_count":348,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzprojects%2FEntityFramework-Plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzprojects%2FEntityFramework-Plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzprojects%2FEntityFramework-Plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzzprojects%2FEntityFramework-Plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zzzprojects","download_url":"https://codeload.github.com/zzzprojects/EntityFramework-Plus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252836102,"owners_count":21811662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","ef6","efcore","entity-framework","entity-framework-core","entityframework"],"created_at":"2024-09-24T20:42:54.129Z","updated_at":"2025-05-07T07:41:24.348Z","avatar_url":"https://github.com/zzzprojects.png","language":"C#","readme":"### Library Powered By\n\nThis library is powered by [Entity Framework Extensions](https://entityframework-extensions.net/?z=github\u0026y=entityframework-plus)\n\n\u003ca href=\"https://entityframework-extensions.net/?z=github\u0026y=entityframework-plus\"\u003e\n\u003ckbd\u003e\n\u003cimg src=\"https://zzzprojects.github.io/images/logo/entityframework-extensions-pub.jpg\" alt=\"Entity Framework Extensions\" /\u003e\n\u003c/kbd\u003e\n\u003c/a\u003e\n\n---\n\n# Entity Framework Plus\nImprove Entity Framework performance and overcome limitations with MUST-HAVE features\n\n## Download\n\nFull Version | NuGet | NuGet Install\n------------ | :-------------: | :-------------:\nZ.EntityFramework.Plus.EFCore | \u003ca href=\"https://www.nuget.org/packages/Z.EntityFramework.Plus.EFCore/\" target=\"_blank\"\u003e\u003cimg src=\"https://zzzprojects.github.io/images/nuget/efcore-full-version-v.svg\" alt=\"download\" /\u003e\u003c/a\u003e\u003ca href=\"https://www.nuget.org/packages/Z.EntityFramework.Plus.EFCore/\" target=\"_blank\"\u003e\u003cimg src=\"https://zzzprojects.github.io/images/nuget/efcore-full-version-d.svg\" alt=\"\" /\u003e\u003c/a\u003e | ```PM\u003e Install-Package Z.EntityFramework.Plus.EFCore```\nZ.EntityFramework.Plus.EF6 | \u003ca href=\"https://www.nuget.org/packages/Z.EntityFramework.Plus.EF6/\" target=\"_blank\"\u003e\u003cimg src=\"https://zzzprojects.github.io/images/nuget/ef6-full-version-v.svg\" alt=\"download\" /\u003e\u003c/a\u003e\u003ca href=\"https://www.nuget.org/packages/Z.EntityFramework.Plus.EF6/\" target=\"_blank\"\u003e\u003cimg src=\"https://zzzprojects.github.io/images/nuget/ef6-full-version-d.svg\" alt=\"\" /\u003e\u003c/a\u003e | ```PM\u003e Install-Package Z.EntityFramework.Plus.EF6```\nZ.EntityFramework.Plus.EF5 | \u003ca href=\"https://www.nuget.org/packages/Z.EntityFramework.Plus.EF5/\" target=\"_blank\"\u003e\u003cimg src=\"https://zzzprojects.github.io/images/nuget/ef5-full-version-v.svg\" alt=\"download\" /\u003e\u003c/a\u003e\u003ca href=\"https://www.nuget.org/packages/Z.EntityFramework.Plus.EF5/\" target=\"_blank\"\u003e\u003cimg src=\"https://zzzprojects.github.io/images/nuget/ef5-full-version-d.svg\" alt=\"\" /\u003e\u003c/a\u003e | ```PM\u003e Install-Package Z.EntityFramework.Plus.EF5```\n\n\u003ca href=\"https://entityframework-plus.net/download\"\u003eMore download options (Full and Standalone Version)\u003c/a\u003e\n\n## Features\n- Batch Operations\n    - [Batch Delete](https://entityframework-plus.net/ef-core-batch-delete)\n    - [Batch Update](https://entityframework-plus.net/ef-core-batch-update)\n- LINQ\n    - [LINQ Dynamic](https://entityframework-plus.net/ef-core-linq-dynamic)\n- Query\n    - [Query Cache](https://entityframework-plus.net/ef-core-query-cache)  \n    - [Query Deferred](https://entityframework-plus.net/ef-core-query-deferred)\n    - [Query DbSetFilter](https://entityframework-plus.net/query-db-set-filter)\n    - [Query Filter](https://entityframework-plus.net/ef-core-query-filter)\n    - [Query Future](https://entityframework-plus.net/ef-core-query-future)\n    - [Query IncludeFilter](https://entityframework-plus.net/ef-core-query-include-filter)\n    - [Query IncludeOptimized](https://entityframework-plus.net/ef-core-query-include-optimized)\n- [Audit](https://entityframework-plus.net/ef-core-audit)\n\n---\n\n**Bulk Operations only available with [Entity Framework Extensions](http://entityframework-extensions.net/)**\n- BulkSaveChanges\n- BulkInsert\n- BulkUpdate\n- BulkDelete\n- BulkMerge\n\n---\n\n## Batch Delete\nDeletes multiples rows in a single database roundtrip and without loading entities in the context.\n\n```csharp\n// using Z.EntityFramework.Plus; // Don't forget to include this.\n\n// DELETE all users which has been inactive for 2 years\nctx.Users.Where(x =\u003e x.LastLoginDate \u003c DateTime.Now.AddYears(-2))\n         .Delete();\n\n// DELETE using a BatchSize\nctx.Users.Where(x =\u003e x.LastLoginDate \u003c DateTime.Now.AddYears(-2))\n         .Delete(x =\u003e x.BatchSize = 1000);\n```\n\n**Support:** EF5, EF6, EF Core\n\n**[Learn more](https://entityframework-plus.net/ef-core-batch-delete)**\n\n## Batch Update\nUpdates multiples rows using an expression in a single database roundtrip and without loading entities in the context.\n\n```csharp\n// using Z.EntityFramework.Plus; // Don't forget to include this.\n\n// UPDATE all users which has been inactive for 2 years\nctx.Users.Where(x =\u003e x.LastLoginDate \u003c DateTime.Now.AddYears(-2))\n         .Update(x =\u003e new User() { IsSoftDeleted = 1 });\n```\n\n**Support:** EF5, EF6, EF Core\n\n**[Learn more](https://entityframework-plus.net/ef-core-batch-update)**\n\n## Query Cache\n**Query cache is the second level cache for Entity Framework.**\n\nThe result of the query is returned from the cache. If the query is not cached yet, the query is materialized and cached before being returned.\n\nYou can specify cache policy and cache tag to control CacheItem expiration.\n\n**Support:**\n\n_Cache Policy_\n\n```csharp\n// The query is cached using default QueryCacheManager options\nvar countries = ctx.Countries.Where(x =\u003e x.IsActive).FromCache();\n\n// (EF5 | EF6) The query is cached for 2 hours\nvar states = ctx.States.Where(x =\u003e x.IsActive).FromCache(DateTime.Now.AddHours(2));\n\n// (EF7) The query is cached for 2 hours without any activity\nvar options = new MemoryCacheEntryOptions() { SlidingExpiration = TimeSpan.FromHours(2)};\nvar states = ctx.States.Where(x =\u003e x.IsActive).FromCache(options);\n```\n\n_Cache Tags_\n\n```csharp\nvar states = db.States.Where(x =\u003e x.IsActive).FromCache(\"countries\", \"states\");\nvar stateCount = db.States.Where(x =\u003e x.IsActive).DeferredCount().FromCache(\"countries\", \"states\");\n\n// Expire all cache entry using the \"countries\" tag\nQueryCacheManager.ExpireTag(\"countries\");\n```\n\n**Support:** EF5, EF6, EF Core\n\n**[Learn more](https://entityframework-plus.net/ef-core-query-cache)**\n\n## Query Deferred\n**Defer the execution of a query which is normally executed to allow some features like Query Cache and Query Future.**\n\n```csharp\n// Oops! The query is already executed, we cannot use Query Cache or Query Future features\nvar count = ctx.Customers.Count();\n\n// Query Cache\nctx.Customers.DeferredCount().FromCache();\n\n// Query Future\nctx.Customers.DeferredCount().FutureValue();\n```\n\u003e All LINQ extensions are supported: Count, First, FirstOrDefault, Sum, etc. \n\n**Support:** EF5, EF6, EF Core\n\n**[Learn more](https://entityframework-plus.net/ef-core-query-deferred)**\n\n## Query Filter\n**Filter query with predicate at global, instance or query level.**\n\n**Support:**\n\n_Global Filter_\n```csharp\n// CREATE global filter\nQueryFilterManager.Filter\u003cCustomer\u003e(x =\u003e x.Where(c =\u003e c.IsActive));\n\nvar ctx = new EntityContext();\n\n// TIP: Add this line in EntitiesContext constructor instead\nQueryFilterManager.InitilizeGlobalFilter(ctx);\n\n// SELECT * FROM Customer WHERE IsActive = true\nvar customer = ctx.Customers.ToList();\n```\n\n_Instance Filter_\n```csharp\nvar ctx = new EntityContext();\n\n// CREATE filter\nctx.Filter\u003cCustomer\u003e(x =\u003e x.Where(c =\u003e c.IsActive));\n\n// SELECT * FROM Customer WHERE IsActive = true\nvar customer = ctx.Customers.ToList();\n```\n\n_Query Filter_\n```csharp\nvar ctx = new EntityContext();\n\n// CREATE filter disabled\nctx.Filter\u003cCustomer\u003e(CustomEnum.EnumValue, x =\u003e x.Where(c =\u003e c.IsActive), false);\n\n// SELECT * FROM Customer WHERE IsActive = true\nvar customer = ctx.Customers.Filter(CustomEnum.EnumValue).ToList();\n```\n\n**Support:** EF5, EF6, EF Core\n\n**[Learn more](https://entityframework-plus.net/ef-core-query-filter)**\n\n## Query Future\n**Query Future allow to reduce database roundtrip by batching multiple queries in the same sql command.**\n\nAll future query are stored in a pending list. When the first future query require a database roundtrip, all query are resolved in the same sql command instead of making a database roundtrip for every sql command.\n\n**Support:**\n\n_Future_\n\n```csharp\n// GET the states \u0026 countries list\nvar futureCountries = db.Countries.Where(x =\u003e x.IsActive).Future();\nvar futureStates = db.States.Where(x =\u003e x.IsActive).Future();\n\n// TRIGGER all pending queries (futureCountries \u0026 futureStates)\nvar countries = futureCountries.ToList();\n```\n\n_FutureValue_\n\n```csharp\n// GET the first active customer and the number of avtive customers\nvar futureFirstCustomer = db.Customers.Where(x =\u003e x.IsActive).DeferredFirstOrDefault().FutureValue();\nvar futureCustomerCount = db.Customers.Where(x =\u003e x.IsActive).DeferredCount().FutureValue();\n\n// TRIGGER all pending queries (futureFirstCustomer \u0026 futureCustomerCount)\nCustomer firstCustomer = futureFirstCustomer.Value;\n```\n\n**Support:** EF5, EF6, EF Core\n\n**[Learn more](https://entityframework-plus.net/ef-core-query-future)**\n\n## Query IncludeFilter\nEntity Framework already support eager loading however the major drawback is you cannot control what will be included. There is no way to load only active item or load only the first 10 comments.\n\n**EF+ Query Include** make it easy:\n```csharp\nvar ctx = new EntityContext();\n\n// Load only active comments\nvar posts = ctx.Post.IncludeFilter(x =\u003e x.Comments.Where(x =\u003e x.IsActive));\n```\n\n**Support:** EF6, EF Core\n\n**[Learn more](https://entityframework-plus.net/ef-core-query-include-filter)**\n\n## Query IncludeOptimized\nImprove SQL generate by Include and filter child collections at the same times!\n\n```csharp\nvar ctx = new EntityContext();\n\n// Load only active comments using an optimized include\nvar posts = ctx.Post.IncludeOptimized(x =\u003e x.Comments.Where(x =\u003e x.IsActive));\n```\n\n**Support:** EF5, EF6, EF Core\n\n**[Learn more](https://entityframework-plus.net/ef-core-query-include-optimized)**\n\n## Audit\nAllow to easily track changes, exclude/include entity or property and auto save audit entries in the database.\n\n**Support:**\n - AutoSave Audit\n - Exclude \u0026 Include Entity\n - Exclude \u0026 Include Property\n - Format Value\n - Ignore Events\n - Property Unchanged\n - Soft Add \u0026 Soft Delete\n\n```csharp\n// using Z.EntityFramework.Plus; // Don't forget to include this.\n\nvar ctx = new EntityContext();\n// ... ctx changes ...\n\nvar audit = new Audit();\naudit.CreatedBy = \"ZZZ Projects\"; // Optional\nctx.SaveChanges(audit);\n\n// Access to all auditing information\nvar entries = audit.Entries;\nforeach(var entry in entries)\n{\n    foreach(var property in entry.Properties)\n    {\n    }\n}\n```\n\nAutoSave audit in your database\n```csharp\nAuditManager.DefaultConfiguration.AutoSavePreAction = (context, audit) =\u003e\n    (context as EntityContext).AuditEntries.AddRange(audit.Entries);\n```\n\n**Support:** EF5, EF6, EF Core\n\n**[Learn more](https://entityframework-plus.net/ef-core-audit)**\n\n## Useful links\n\n- [Website](https://entityframework-plus.net/)\n- [Documentation](https://entityframework-plus.net/batch-delete)\n- [Online Examples](https://entityframework-plus.net/online-examples) \n- You can also consult tons of Entity Framework Plus questions on \n[Stack Overflow](https://stackoverflow.com/questions/tagged/entity-framework-plus)\n\n## Contribute\n\nThe best way to contribute is by **spreading the word** about the library:\n\n - Blog it\n - Comment it\n - Star it\n - Share it\n \nA **HUGE THANKS** for your help.\n\n## More Projects\n\n- Projects:\n   - [EntityFramework Extensions](https://entityframework-extensions.net/)\n   - [Dapper Plus](https://dapper-plus.net/)\n   - [C# Eval Expression](https://eval-expression.net/)\n- Learn Websites\n   - [Learn EF Core](https://www.learnentityframeworkcore.com/)\n   - [Learn Dapper](https://www.learndapper.com/)\n- Online Tools:\n   - [.NET Fiddle](https://dotnetfiddle.net/)\n   - [SQL Fiddle](https://sqlfiddle.com/)\n   - [ZZZ Code AI](https://zzzcode.ai/)\n- and much more!\n\nTo view all our free and paid projects, visit our website [ZZZ Projects](https://zzzprojects.com/).\n","funding_links":["https://github.com/sponsors/zzzprojects","https://zzzprojects.com/contribute"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzzprojects%2Fentityframework-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzzzprojects%2Fentityframework-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzzprojects%2Fentityframework-plus/lists"}