3

最终部署到使用 Entity Framework Code First 和 MySql 构建的新站点后,一个令人烦恼的问题是缓存视图元数据时经常遇到的暂停。这似乎比应用程序池被回收的频率要高得多。(?)

我想对于一个流量源源不断的网站来说,这可能不会经常被注意到。对于一个流量不频繁的新站点,感觉就像每次我访问该站点时,呈现第一页都会有 4-5 秒的延迟。

所以我追踪了以下链接:

http://msdn.microsoft.com/en-us/library/bb896240.aspx

http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d

EF Power Tools 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 Q&A 部分的其他几个人正在报告它。

所以,简而言之,我如何首先为 EF 4.3 代码预生成视图,最好以一种可以插入自动构建过程的方式?

4

2 回答 2

1

Pawel 回答了我的相关问题:

实体框架初始化很慢——我能做些什么来更快地引导它?

通过构建 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 模型的(另一个)手动步骤。

真的,他们需要一个警告说,不要使用 EF WITH > 500 TABLES,使用它变得越来越烦人。

于 2012-07-18T13:17:35.533 回答
0

我在运行 VS2010、EF v4.3.1 和 Entity Framework Power Tools Beta 2 时遇到了同样的错误。我的解决方案是以管理员身份运行 Visual Studio。(通过右键单击图标并从上下文菜单中选择“以管理员身份运行”来完成。)此时我能够使用 EFPT 中的“生成视图”选项。

于 2012-10-14T23:10:07.500 回答