实体框架 - 初始保存缓慢 [英] Entity Framework - Initial Save is slow
问题描述
有没有人经历过这个问题,知道一个方法?
谢谢
问题解决:生成模型的视图。其原因及其解决方法如下: http:// msdn.microsoft.com/en-us/library/bb896240.aspx 。
简而言之,每次创建一个新的上下文实体框架生成一组用于访问数据库的视图。这种视图生成是一项昂贵的操作,并且解释了所遇到的重要的初始延迟。通过预先考虑这些观点,避免了这种初始延迟。
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
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.
这篇关于实体框架 - 初始保存缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!