Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Entity framework 使用CodeFirst.DontDropDbJustCreateTablesIfModelChanged会导致EF 4.3中ObjectStateManager的附件问题_Entity Framework_Ef Code First_Appharbor - Fatal编程技术网

Entity framework 使用CodeFirst.DontDropDbJustCreateTablesIfModelChanged会导致EF 4.3中ObjectStateManager的附件问题

Entity framework 使用CodeFirst.DontDropDbJustCreateTablesIfModelChanged会导致EF 4.3中ObjectStateManager的附件问题,entity-framework,ef-code-first,appharbor,Entity Framework,Ef Code First,Appharbor,[编辑]:该应用程序在我的本地计算机中运行良好,但无法在计算机中运行。在我的站点的初始加载时,我会得到这个,如果我重新加载页面,那么我会得到下面提到的错误。正如appharbor的管理员所提到的,他们正在处理NewRelic和ninject的问题。但我不确定我的第二个错误是否仍然与appharbor的NewRelic问题有关。Devtalk.EF.CodeFirst.DontDropDbJustCreateTablesIfModelChanged是否可以与EF 4.3一起正常工作?我只是等待他们

[编辑]:该应用程序在我的本地计算机中运行良好,但无法在计算机中运行。在我的站点的初始加载时,我会得到这个,如果我重新加载页面,那么我会得到下面提到的错误。正如appharbor的管理员所提到的,他们正在处理NewRelic和ninject的问题。但我不确定我的第二个错误是否仍然与appharbor的NewRelic问题有关。Devtalk.EF.CodeFirst.DontDropDbJustCreateTablesIfModelChanged是否可以与EF 4.3一起正常工作?我只是等待他们的更新吗

[InvalidOperationException: The object cannot be detached because it is not attached to the ObjectStateManager.]
   at System.Data.Objects.ObjectContext.Detach(Object entity, EntitySet expectedEntitySet)
   at System.Data.Objects.ObjectContext.Detach(Object entity)
   at Devtalk.EF.CodeFirst.DontDropDbJustCreateTablesIfModelChanged`1.SaveModelHashToDatabase(T context, String modelHash, ObjectContext objectContext)
   at Devtalk.EF.CodeFirst.DontDropDbJustCreateTablesIfModelChanged`1.InitializeDatabase(T context)
   at System.Data.Entity.Database.<>c__DisplayClass2`1.<SetInitializerInternal>b__0(DbContext c)
   at System.Data.Entity.Internal.InternalContext.<>c__DisplayClass8.<PerformDatabaseInitialization>b__6()
   at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
   at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
   at System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c)
   at System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
   at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
   at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
   at Core.Repository`2.Find(Expression`1 predicate) in d:\temp\2otuf0q2.xtn\input\Domain\Core\Repository.cs:line 52
   at Data.RegistrantRepository.GetAllRegistrant() in d:\temp\2otuf0q2.xtn\input\Data\Data\RegistrantRepository.cs:line 20
   at IPOD.Controllers.HomeController.Index() in d:\temp\2otuf0q2.xtn\input\IPOD\Controllers\HomeController.cs:line 28
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
   at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
   at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
[InvalidOperationException:无法分离该对象,因为它未附加到ObjectStateManager。]
位于System.Data.Objects.ObjectContext.Detach(对象实体,EntitySet expectedEntitySet)
位于System.Data.Objects.ObjectContext.Detach(对象实体)
在Devtalk.EF.CodeFirst.DontDropDbJustCreateTablesIfModelChanged`1.SaveModelHashToDatabase(T上下文、字符串modelHash、ObjectContext ObjectContext)
在Devtalk.EF.CodeFirst.DontDropDbJustCreateTablesIfModelChanged`1.InitializeDatabase(T上下文)
在System.Data.Entity.Database.c__DisplayClass2`1.b__0(DbContext c)中
在System.Data.Entity.Internal.InternalContext.c__DisplayClass8.b__6()中
位于System.Data.Entity.Internal.InternalContext.PerforminizationAction(操作操作)
位于System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()处
位于System.Data.Entity.Internal.LazyInternalContext.b_uu4(InternalContext c)
在System.Data.Entity.Internal.RetryAction`1.PerformAction(输入)
位于System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 Action)
在System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()中
位于System.Data.Entity.Internal.InternalContext.Initialize()处
位于System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(类型entityType)
位于System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
位于System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
位于System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
在System.Linq.Queryable.Where[TSource](IQueryable`1源,表达式`1谓词)
在d:\temp\2otuf0q2.xtn\input\Domain\Core\Repository.cs中的Core.Repository`2.Find(表达式`1谓词):第52行
位于d:\temp\2otuf0q2.xtn\input\Data\Data\registentrepository.cs中的Data.registentrepository.GetAllRegistrant():第20行
在d:\temp\2otuf0q2.xtn\input\IPOD\Controllers\HomeController.cs中的IPOD.Controllers.HomeController.Index()处:第28行
在lambda_方法中(闭包、控制器基、对象[])
位于System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller,Object[]参数)
位于System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext ControllerContext,IDictionary`2参数)
位于System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext ControllerContext,ActionDescriptor ActionDescriptor,IDictionary`2参数)
在System.Web.Mvc.ControllerActionInvoker.c_uuDisplayClass15.b_uuu12()中
位于System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter筛选器、ActionExecutingContext预文本、Func`1 continuation)
在System.Web.Mvc.ControllerActionInvoker.c_uuDisplayClass15.c_uuDisplayClass17.b_uu14()中
位于System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext ControllerContext,IList`1筛选器,ActionDescriptor ActionDescriptor,IDictionary`2参数)
位于System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext ControllerContext,String actionName)
在System.Web.Mvc.Controller.ExecuteCore()上
在System.Web.Mvc.ControllerBase.Execute(RequestContext-RequestContext)中
位于System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext RequestContext)
在System.Web.Mvc.MvcHandler.c_uuudisplayClass6.c_uudisplayClassB.b_uu5()中
在System.Web.Mvc.Async.AsyncResultRapper.c__DisplayClass1.b__0()中
在System.Web.Mvc.Async.AsyncResultRapper.c_uuu显示类8`1.b_uuu7(IAsyncResult)
位于System.Web.Mvc.Async.AsyncResultRapper.WrappedAsyncResult`1.End()
在System.Web.Mvc.Async.asyncResultRapper.End[TResult](IAsyncResult asyncResult,对象标记)
在System.Web.Mvc.Async.AsyncResultRapper.End(IAsyncResult asyncResult,对象标记)
在System.Web.Mvc.MvcHandler.c_udisplayClasse.b_ud()中
在System.Web.Mvc.SecurityUtil.b_0(操作f)
位于System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(操作)
位于System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
在System.Web.Mvc.MvcHandler.System.Web.IHTTPassynchandler.EndProcessRequest中(IAsyncResult结果)
在System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()中
在System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值&同步完成)

对我来说,初始化器似乎正在尝试更新EdmMetadata表-至少这是我的推断:

Devtalk.EF.CodeFirst.DontDropDbJustCreateTablesIfModelChanged`1.SaveModelHashToDatabase(T context, String modelHash, ObjectContext objectContext) 
在EF 4.3中,不会创建EdmMeatadata表(如果数据库中有一个表且模型没有更改,则将使用该表-即从4.1/4.2升级到4.3+,有关更多详细信息,请参阅:)


在4.3版本中,如果您的模型发生更改,并且您需要更新数据库,但不希望实际删除并重新创建数据库,那么您希望使用迁移。看看这个walkthough:

人们需要更多的数据、模型等。实际上,我们刚刚在SO上找到了这个线程:在那里可以看到初始值设定项的来源。它试图使用EdmMetadata表,因此我认为它与EF 4.3+不兼容。谢谢!Appharbor需要更新其EF 4.3部署指南:D