最终部署到使用 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 代码预生成视图,最好以一种可以插入自动构建过程的方式?