实体框架在批量插入/更新/删除操作时可能会非常慢.即使是经常建议的关闭 AutoDetectChanges 和/或 ValidateOnSaveEnabled 的调整也并不总是有帮助.
Entity Framework can be very slow on mass insert/update/delete operations. Even the often suggested tweaks to turn off AutoDetectChanges and/or ValidateOnSaveEnabled does not always help.
我在 NuGet 上遇到过 Z.EntityFramework.Extensions,但它似乎是一个商业产品,只能在一段时间内工作.
I have come across the Z.EntityFramework.Extensions on NuGet, but it seems to be a commercial product, which will only work for a certain period of time.
https://www.nuget.org/packages/Z.EntityFramework.Extensions/
到目前为止,我真的只需要 BulkInsert()、BulkUpdate() 和 BulkDelete().
So far, I really only need BulkInsert(), BulkUpdate() and BulkDelete().
我的问题是:
是否有任何可靠的非商业库,其功能与 Z.EntityFramework.Extensions 几乎相同?
感谢任何提示!
免责声明:我是 实体框架扩展
你是对的.这是一个商业产品.
You are right. This is a commercial product.
每个月都提供免费试用,但您必须为生产环境购买产品.
批量插入
对于 BulkInsert,有一些免费的替代方案,但要小心,它们不支持所有继承 &关联并且不再受支持:
For BulkInsert, there are some free alternatives but be careful, they don't support all inheritances & associations and are no longer supported:
免责声明:我是Entity Framework Plus的所有者
用于批量更新&&批量删除,可以使用这个库:
For Batch Update && Batch Delete, you can use this library:
// DELETE all users which has been inactive for 2 years
ctx.Users.Where(x => x.LastLoginDate < DateTime.Now.AddYears(-2))
.Delete();
// UPDATE all users which has been inactive for 2 years
ctx.Users.Where(x => x.LastLoginDate < DateTime.Now.AddYears(-2))
.Update(x => new User() { IsSoftDeleted = 1 });
这篇关于是否有 Z.EntityFramework.Extensions 的非商业替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!