使用ASP.NET Web API中的实体框架插入数据库中的多行
我有一种算法,该算法在列表中创建大量数据,必须将其插入数据库表中。我可以将循环通过实体保存更改,但是有比这更好的方法。
I'm having an algorithm which creates a huge set of data in lists which have to be inserted into a database table. I can just put a loop through the entity save changes but is there a bit better way than that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
addrange
将多行插入表中:这样工作正常,但建议使用EF的扩展名为
efcore.bulkextensions.bulkextensions
具有高性能:You can use
AddRange
for insert multiple rows into table like this:That works fine but it's recommended to use an extension for EF called
EFCore.BulkExtensions
with high performance like this: