Entity Framework - Initial Save is slow
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.
开发者_StackOverflow中文版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.
精彩评论