【发布时间】:2009-07-19 05:26:20
【问题描述】:
我们正在为我们的 ASP.NET 应用程序使用 ADO.NET 实体。
我了解到预生成的视图提高了性能。参考博文,
http://blogs.msdn.com/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx,我生成了视图。命名空间和类生成为
namespace Edm_EntityMappingGeneratedViews
{
/// <Summary>
/// The type contains views for EntitySets and AssociationSets that were generated at design time.
/// </Summary>
public sealed class ViewsForBaseEntitySets4D4A6E0AA7AF6B2298FABB4F22235831 : System.Data.Mapping.EntityViewContainer
{
/// <Summary>
/// The constructor stores the views for the extents and also the hash values generated based on the metadata and mapping closure and views
/// </Summary>
public ViewsForBaseEntitySets4D4A6E0AA7AF6B2298FABB4F22235831()
{
this.EdmEntityContainerName = "JSEntities";
我将此添加到我的数据层并测试性能。看不出有多大改善。 CPU 使用率总是达到 20-30% 利用率(响应时间很好)并在 500 毫秒 - 1 秒内降低到 0%。我认为由于每次都生成视图,CPU 利用率会很高。
我无法理解实体框架如何知道这是我为模型预先生成的视图类,尽管 MyModel.edmx 和 MyModel.Views.cs 与文件名匹配。
我是否应该更新 Web.Config 或 App.Config 以将 View 类映射到某个地方的模型?
请澄清。
【问题讨论】:
-
检查哪个进程正在使用 CPU。您的 SQL Server 是否在同一台机器上?