Entity Framework - Initial Save is slow

蹲街弑〆低调 提交于 2019-12-12 10:12:59

问题


We are implementing a system using EF4 and WPF. We are noticing an issue with the initial saving of data: when the initial SaveChanges is run there is a 4 to 6 second delay when context.SaveChanges() command is run. Every subsequent SaveChanges is very fast with no noticable delay. This is not a major issue - but an annoyance none-the-less.

Has anyone out there experienced this issue and know a way around it?

Thanks


回答1:


Problem solved: the answer was to pre-generate the model's views. The reason for this and method to implement the solution is found here: http://msdn.microsoft.com/en-us/library/bb896240.aspx.

In short - everytime a new context is created Entity Framework generates a set of views used to access the database. This view generation is an expensive operation and accounts for the significant initial delay encountered. By precomiling these views this initial delay is avoided.



来源:https://stackoverflow.com/questions/3240839/entity-framework-initial-save-is-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!