2

我面临一个问题,即 EF 需要花费大量时间(跨越数小时)来初始化模型。该模型如下所示。从 A1 派生的类大约有 20 个,从 A2 派生的类大约有 30 个。

在此处输入图像描述

我不得不从 TPT 转向 TPH 策略来解决与内存使用相关的问题。从那时起,我试图弄清楚这个问题。

问题是通过创建一个类型为“A”的单个实例,将其添加到List<A>另一个实体的属性并提交这些更改而产生的。此刻,它已经花费了大约 2.5 小时,还没有提交更改!

闯入代码(等了大约一个小时完成后),调用堆栈为:

System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition, System.Data.Common.Utils.Boolean.Vertex then, System.Data.Common.Utils.Boolean.Vertex else) + 0x14e bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.And.AnonymousMethod__1(System.Data.Common.Utils.Boolean.Vertex left, System.Data.Common.Utils.Boolean.Vertex right) + 0x29 bytes 
System.Core.dll!System.Linq.Enumerable.Aggregate<System.Data.Common.Utils.Boolean.Vertex,System.Data.Common.Utils.Boolean.Vertex>(System.Collections.Generic.IEnumerable<System.Data.Common.Utils.Boolean.Vertex> source, System.Data.Common.Utils.Boolean.Vertex seed, System.Func<System.Data.Common.Utils.Boolean.Vertex,System.Data.Common.Utils.Boolean.Vertex,System.Data.Common.Utils.Boolean.Vertex> func) + 0x99 bytes 
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.And(System.Collections.Generic.IEnumerable<System.Data.Common.Utils.Boolean.Vertex> children) + 0x90 bytes   
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.ToDecisionDiagramConverter<System.Data.Common.Utils.Boolean.DomainConstraint<System.Data.Mapping.ViewGeneration.Structures.BoolLiteral,System.Data.Mapping.ViewGeneration.Structures.Constant>>.VisitAnd(System.Data.Common.Utils.Boolean.AndExpr<System.Data.Common.Utils.Boolean.DomainConstraint<System.Data.Mapping.ViewGeneration.Structures.BoolLiteral,System.Data.Mapping.ViewGeneration.Structures.Constant>> expression) + 0x77 bytes 
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.AndExpr<System.__Canon>.Accept<System.__Canon>(System.Data.Common.Utils.Boolean.Visitor<System.__Canon,System.__Canon> visitor) + 0xc bytes 
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.ToDecisionDiagramConverter<System.Data.Common.Utils.Boolean.DomainConstraint<System.Data.Mapping.ViewGeneration.Structures.BoolLiteral,System.Data.Mapping.ViewGeneration.Structures.Constant>>.TranslateToRobdd(System.Data.Common.Utils.Boolean.BoolExpr<System.Data.Common.Utils.Boolean.DomainConstraint<System.Data.Mapping.ViewGeneration.Structures.BoolLiteral,System.Data.Mapping.ViewGeneration.Structures.Constant>> expr, System.Data.Common.Utils.Boolean.ConversionContext<System.Data.Common.Utils.Boolean.DomainConstraint<System.Data.Mapping.ViewGeneration.Structures.BoolLiteral,System.Data.Mapping.ViewGeneration.Structures.Constant>> context) + 0x72 bytes 
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Converter<System.Data.Common.Utils.Boolean.DomainConstraint<System.Data.Mapping.ViewGeneration.Structures.BoolLiteral,System.Data.Mapping.ViewGeneration.Structures.Constant>>.Converter(System.Data.Common.Utils.Boolean.BoolExpr<System.Data.Common.Utils.Boolean.DomainConstraint<System.Data.Mapping.ViewGeneration.Structures.BoolLiteral,System.Data.Mapping.ViewGeneration.Structures.Constant>> expr, System.Data.Common.Utils.Boolean.ConversionContext<System.Data.Common.Utils.Boolean.DomainConstraint<System.Data.Mapping.ViewGeneration.Structures.BoolLiteral,System.Data.Mapping.ViewGeneration.Structures.Constant>> context) + 0x46 bytes 
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.QueryRewriting.FragmentQueryProcessor.IsSatisfiable(System.Data.Mapping.ViewGeneration.Structures.BoolExpression condition) + 0xac bytes  
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.QueryRewriting.FragmentQueryProcessor.IsSatisfiable(System.Data.Mapping.ViewGeneration.QueryRewriting.FragmentQuery query) + 0x8 bytes    
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.Structures.CellTreeNode.IsEmptyRightFragmentQuery.get() + 0x1e bytes  
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.BasicViewGenerator.IsDisjoint(System.Data.Mapping.ViewGeneration.Structures.CellTreeNode n1, System.Data.Mapping.ViewGeneration.Structures.CellTreeNode n2) + 0xbb bytes  
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.BasicViewGenerator.TryAddChildToGroup(System.Data.Mapping.ViewGeneration.Structures.CellTreeOpType opTypeToIsolate, System.Data.Mapping.ViewGeneration.Structures.CellTreeNode childNode, System.Data.Mapping.ViewGeneration.Structures.OpCellTreeNode groupNode) + 0x3f bytes    
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.BasicViewGenerator.IsolateByOperator(System.Data.Mapping.ViewGeneration.Structures.CellTreeNode rootNode, System.Data.Mapping.ViewGeneration.Structures.CellTreeOpType opTypeToIsolate) + 0x1eb bytes 
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.BasicViewGenerator.CreateViewExpression() + 0xeb bytes    
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.QueryRewriting.QueryRewriter.GenerateViewComponents() + 0x12a bytes   
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.ViewGenerator.GenerateViewsForExtentAndType(System.Data.Metadata.Edm.EdmType generatedType, System.Data.Mapping.ViewGeneration.ViewgenContext context, System.Data.Mapping.ViewGeneration.Structures.CqlIdentifiers identifiers, System.Data.Common.Utils.KeyToListMap<System.Data.Metadata.Edm.EntitySetBase,System.Data.Mapping.ViewGeneration.GeneratedView> views, System.Data.Mapping.ViewGeneration.ViewGenMode mode) + 0x2f bytes  
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.ViewGenerator.GenerateDirectionalViewsForExtent(System.Data.Mapping.ViewGeneration.Structures.ViewTarget viewTarget, System.Data.Metadata.Edm.EntitySetBase extent, System.Data.Mapping.ViewGeneration.Structures.CqlIdentifiers identifiers, System.Data.Common.Utils.KeyToListMap<System.Data.Metadata.Edm.EntitySetBase,System.Data.Mapping.ViewGeneration.GeneratedView> views) + 0x58 bytes  
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.ViewGenerator.GenerateDirectionalViews(System.Data.Mapping.ViewGeneration.Structures.ViewTarget viewTarget, System.Data.Mapping.ViewGeneration.Structures.CqlIdentifiers identifiers, System.Data.Common.Utils.KeyToListMap<System.Data.Metadata.Edm.EntitySetBase,System.Data.Mapping.ViewGeneration.GeneratedView> views) + 0xce bytes  
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.ViewGenerator.GenerateAllBidirectionalViews(System.Data.Common.Utils.KeyToListMap<System.Data.Metadata.Edm.EntitySetBase,System.Data.Mapping.ViewGeneration.GeneratedView> views, System.Data.Mapping.ViewGeneration.Structures.CqlIdentifiers identifiers) + 0xd7 bytes  
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.ViewgenGatekeeper.GenerateViewsFromCells(System.Collections.Generic.List<System.Data.Mapping.ViewGeneration.Structures.Cell> cells, System.Data.Mapping.ViewGeneration.ConfigViewGenerator config, System.Data.Mapping.ViewGeneration.Structures.CqlIdentifiers identifiers, System.Data.Mapping.StorageEntityContainerMapping containerMapping) + 0x1aa bytes    
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.ViewgenGatekeeper.GenerateViewsFromMapping(System.Data.Mapping.StorageEntityContainerMapping containerMapping, System.Data.Mapping.ViewGeneration.ConfigViewGenerator config) + 0xbf bytes    
System.Data.Entity.dll!System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.SerializedGenerateViews(System.Data.Mapping.StorageEntityContainerMapping entityContainerMap, System.Collections.Generic.Dictionary<System.Data.Metadata.Edm.EntitySetBase,System.Data.Mapping.ViewGeneration.GeneratedView> resultDictionary) + 0x3a bytes  
System.Data.Entity.dll!System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.SerializedGetGeneratedViews(System.Data.Metadata.Edm.EntityContainer container) + 0xd2 bytes 
System.Data.Entity.dll!System.Data.Common.Utils.Memoizer<System.__Canon,System.__Canon>.Evaluate.AnonymousMethod__0() + 0x13 bytes  
System.Data.Entity.dll!System.Data.Common.Utils.Memoizer<System.Data.Metadata.Edm.EntityContainer,System.Collections.Generic.Dictionary<System.Data.Metadata.Edm.EntitySetBase,System.Data.Mapping.ViewGeneration.GeneratedView>>.Result.GetValue() + 0x69 bytes    
System.Data.Entity.dll!System.Data.Common.Utils.Memoizer<System.Data.Metadata.Edm.EntityContainer,System.Collections.Generic.Dictionary<System.Data.Metadata.Edm.EntitySetBase,System.Data.Mapping.ViewGeneration.GeneratedView>>.Evaluate(System.Data.Metadata.Edm.EntityContainer arg) + 0x6e bytes   
System.Data.Entity.dll!System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.GetGeneratedView(System.Data.Metadata.Edm.EntitySetBase extent, System.Data.Metadata.Edm.MetadataWorkspace workspace, System.Data.Mapping.StorageMappingItemCollection storageMappingItemCollection) + 0x49 bytes    
System.Data.Entity.dll!System.Data.Mapping.Update.Internal.ViewLoader.InitializeEntitySet(System.Data.Metadata.Edm.EntitySetBase entitySetBase, System.Data.Metadata.Edm.MetadataWorkspace workspace) + 0x74 bytes  
System.Data.Entity.dll!System.Data.Mapping.Update.Internal.ViewLoader.SyncInitializeEntitySet<System.__Canon,System.__Canon>(System.Data.Metadata.Edm.EntitySetBase entitySetBase, System.Data.Metadata.Edm.MetadataWorkspace workspace, System.Func<System.__Canon,System.__Canon> evaluate, System.__Canon arg) + 0xdf bytes  
System.Data.Entity.dll!System.Data.Mapping.Update.Internal.ViewLoader.SyncGetValue<System.Data.Metadata.Edm.AssociationSet,System.Data.Mapping.Update.Internal.AssociationSetMetadata>(System.Data.Metadata.Edm.EntitySetBase entitySetBase, System.Data.Metadata.Edm.MetadataWorkspace workspace, System.Collections.Generic.Dictionary<System.Data.Metadata.Edm.AssociationSet,System.Data.Mapping.Update.Internal.AssociationSetMetadata> dictionary, System.Data.Metadata.Edm.AssociationSet key) + 0x9c bytes  
System.Data.Entity.dll!System.Data.Mapping.Update.Internal.UpdateTranslator.ValidateAndRegisterStateEntry(System.Data.IEntityStateEntry stateEntry) + 0x109 bytes   
System.Data.Entity.dll!System.Data.Mapping.Update.Internal.UpdateTranslator.LoadStateEntry(System.Data.IEntityStateEntry stateEntry) + 0x23 bytes   
System.Data.Entity.dll!System.Data.Mapping.Update.Internal.UpdateTranslator.PullModifiedEntriesFromStateManager() + 0x156 bytes 
System.Data.Entity.dll!System.Data.Mapping.Update.Internal.UpdateTranslator.ProduceCommands() + 0x1a bytes  
System.Data.Entity.dll!System.Data.Mapping.Update.Internal.UpdateTranslator.Update(System.Data.IEntityStateManager stateManager, System.Data.IEntityAdapter adapter) + 0xc9 bytes   
System.Data.Entity.dll!System.Data.EntityClient.EntityAdapter.Update(System.Data.IEntityStateManager entityCache) + 0x93 bytes  
System.Data.Entity.dll!System.Data.Objects.ObjectContext.SaveChanges(System.Data.Objects.SaveOptions options) + 0x23c bytes 
EntityFramework.dll!System.Data.Entity.Internal.InternalContext.SaveChanges() + 0x144 bytes 
EntityFramework.dll!System.Data.Entity.Internal.LazyInternalContext.SaveChanges() + 0x36 bytes  
EntityFramework.dll!System.Data.Entity.DbContext.SaveChanges() + 0x35 bytes
4

1 回答 1

2

从您显示的堆栈跟踪来看,在我看来问题出在视图生成中。由于您首先使用代码,因此我鼓励您尝试EF6,其中包含用于视图生成的性能改进。对于以前的版本作为解决方法,您可以预先生成视图(例如,使用 EF Power Tools 或我创建的模板http://visualstudiogallery.msdn.microsoft.com/ae7730ce-ddab-470f-8456-1b313cd2c44d)。创建视图仍然需要很长时间,但它将是在设计时而不是运行时。

于 2013-01-15T00:22:20.883 回答