在最终部署到使用实体框架代码优先和MySql构建的新站点之后,一个令人恼火的问题是在缓存视图元数据时经常会遇到停顿。这似乎比回收应用程序池的频率要高得多。(?)
我猜对于一个流量不变的网站来说,这可能不会经常被注意到。对于一个流量不频繁的新站点,感觉每次我访问该站点时,呈现第一个页面都会有4-5秒的延迟。
所以我找到了以下链接:
http://msdn.microsoft.com/en-us/library/bb896240.aspx
http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d
EF电动工具CTP1看起来很有希望,除了它似乎在EF 4.3中被破坏了,并且已经几个月没有更新了。此外,我不确定该工具如何适用于我们的自动化构建过程。
EF Power Tools正在使用的OptimizeContext()或WriteEdmx()方法抛出此错误
System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. ---> System.Data.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. ---> System.Data.SqlClient.SqlException:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)我最初认为这可能与MySql相关,但EF Power Tools问答部分上的其他几个人正在报告它。
那么,简而言之,我如何首先为EF4.3代码预先生成视图,最好是以一种可以插入到自动构建过程中的方式?
发布于 2012-07-18 21:17:36
Pawel回答了我的相关问题:
Entity Framework initialization is SLOW -- what can I do to bootstrap it faster?
通过构建T4模板:
http://blog.3d-logic.com/2012/05/28/entity-framework-code-first-and-pre-generated-views/
它也不是完美的,但比我见过的任何其他东西都更有用。
然后,您可以执行以下操作:
http://www.platinumbay.com/blogs/dotneticated/archive/2009/08/28/running-t4-templates-with-msbuild.aspx
将其添加到构建过程中,但它有点慢,所以您可能希望将其作为更新EF模型的(另一个)手动步骤。
真的,他们需要一个警告,不要使用> 500表的EF,使用它会变得越来越烦人。
发布于 2012-10-15 07:10:08
当我运行VS2010,EF v4.3.1和Entity Framework Power Tools Beta2时,我也遇到了同样的错误。(右键单击图标并从上下文菜单中选择“以管理员身份运行”即可完成。)在这一点上,我能够使用EFPT中的“生成视图”选项。
https://stackoverflow.com/questions/9888789
复制相似问题