实体框架需要大量的时间初始化模型 [英] Entity Framework taking a lot of time initializing model

查看:119
本文介绍了实体框架需要大量的时间初始化模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正面临着一个问题,EF花了很多时间(跨越时间)来初始化模型。模型如下。大约有20个班级来自A1,大约有30个班级从A2派生。





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



问题是通过创建一个类型为'A'的单个实例生成,将其添加到code>列出< A> 属性,并提交这些更改。在这一刻,它已经需要大约2.5个小时,还没有做出改变!



打破代码(等待大约一个小时后完成),调用堆栈是:

  System.Data.Entity.dll!System.Data.Common.Utils.BooleanSolver .ItThenElse(System.Data.Common.Utils.Boolean.Vertex condition,System.Data.Common.Utils.Boolean.Vertex then,System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e bytes 
系统.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条件,System.Data.Common.Utils.Boolean.Vertex然后,System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
System.Data.Entity.dll!System.Data.Common.Utils .Boolea n.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条件,System.Data.Common.Utils.Boolean.Vertex然后System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
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.Boo lean.Vertex条件,System.Data.Common.Utils.Boolean.Vertex然后,System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e字节
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然后,System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e字节
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data。 Common.Utils.Boolean.Vertex条件,System.Data.Common.Utils.Boolean.Vertex然后,System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
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条件,System.Data.Common.Utils.Boolean.Vertex然后,System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
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然后System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
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.Bo olean.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然后,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然后,System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
System.D ata.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然后System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e字节
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。顶点条件,System.Data.Common.Utils.Boolean.Vertex然后System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e字节
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.Boole an.Vertex条件,System.Data.Common.Utils.Boolean.Vertex然后System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e字节
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然后,System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e字节
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data。 Common.Utils.Boolean.Vertex条件,System.Data.Common.Utils.Boolean.Vertex然后,System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
System.Data.Entity.dll! System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition,System.Data.Common.Utils.Bo olean.Vertex然后System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data .Common.Utils.Boolean.Vertex条件,System.Data.Common.Utils.Boolean.Vertex然后,System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
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然后System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
System.Data.Entity.dll!System.Data.Common.Utils.Boolean.Solver.IfThenElse (System.Data.Common.Utils.Boolean.Vertex条件,System.Data.Common.Utils.Boolean.Vertex然后,System.Data.Common.Utils.Bool e.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然后,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.Dat a.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然后System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e字节
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.So lver.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。顶点条件,System.Data.Common.Utils.Boolean.Vertex然后System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e字节
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条件,System.Data.Common.Utils.Boolean.Vertex然后System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
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然后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条件,System.Data.Common.Utils.Boolean.Vertex然后System.Data.Common.Utils.Boolean.Vertex其他)+ 0x14e字节
System.Data.Entity.dll!系统.Data.Common.Utils.Boolean.Solver.IfThenElse(System.Data.Common.Utils.Boolean.Vertex condition,System.Data.Common.Utils.Bool e.Vertex然后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条件,System.Data.Common.Utils.Boolean.Vertex然后,System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
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然后System.Data.Common.Utils.Boolean.Vertex else)+ 0x14e个字节
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.Boolea n.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然后,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字节
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<系统.__佳能> .Accept<系统。佳能>(System.Data.Common.Utils.Boolean.Visitor<系统.__佳能,系统。佳能>访客)+ 0xc字节
System.Data.Entity.dll!系统.Data.Common.Utils.Boole an.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> >上下文)+ 0x72字节
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.M apping.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.ViewGeneratio n.Structures.CellTreeNode rootNode,System.Data.Mapping.ViewGeneration.Structures.CellTreeOpType opTypeToIsolate)+ 0x1eb bytes
System.Data.Entity.dll!System.Data.Mapping.ViewGeneration.BasicViewGenerator.CreateViewExpression()+ 0xeb字节
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 identifier,System.Data.Common.Utils.KeyToListMap< System.Data.Metadata.Edm.EntitySetBase,System.Data.Mapping.ViewGeneration.GeneratedView>视图,System.Data.Mapping.ViewGeneration.ViewGenMode模式)+ 0x2f字节
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 identifier,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 identifier,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.ViewGe nerator.GenerateAllBidirectionalViews(System.Data.Common.Utils.KeyToListMap< System.Data.Metadata.Edm.EntitySetBase,System.Data.Mapping.ViewGeneration.GeneratedView>视图,System.Data.Mapping.ViewGeneration.Structures.CqlIdentifiers标识符)+ 0xd7字节
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 identifier,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 $ b $系统数据。 ; 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 System.Data.Mapping.ViewGeneration.GeneratedView> .Evaluate ()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<系统.__佳能,系统.__佳能>评估,系统.__佳能arg)+ 0xdf字节
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>字典,System.Data.Metadata.Edm.AssociationSet键)+ 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 $系统ger()+ 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适配器)+ 0xc9个字节
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


解决方案

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


I'm facing an issue with EF taking a lot of time (spanning hours) to initialize models. The model is as given below. There are around 20 classes which are derived from A1, and about 30 classes which derive from A2.

I had to move from TPT to TPH strategy to fix an issue related to memory usage. And since then I'm trying to figure out this issue.

The issue is produced by just creating a single instance of type 'A', adding it to a List<A> property of another entity and committing those changes. At this moment, it has already taken about 2.5 hours, and still hasn't committed the changes yet!

Breaking into the code (after waiting for about an hour to finish), the call stack is:

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

解决方案

From the stacktrace you showed it appears to me that the problem is in View Generation. Since you are using code first I would encourage you to try EF6 which contains performance improvements for view generation. For previous versions as a workaround you can pre-generate views (e.g. using EF Power Tools or a template I created http://visualstudiogallery.msdn.microsoft.com/ae7730ce-ddab-470f-8456-1b313cd2c44d). It will still take long to create the view but it will be at design time and not runtime.

这篇关于实体框架需要大量的时间初始化模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆