0

[EDIT]: The application works fine in my local but won't run in AppHarbor. At the initial load of my site, I'd get this error mentioned in another question, if I reload the page then I'd get the error mentioned below. As mentioned by appharbor's Admin, they are working on the problem with new relic and ninject. But I'm not quite sure if my 2nd error is still related with appharbor's issue with new relic. Does Devtalk.EF.CodeFirst.DontDropDbJustCreateTablesIfModelChanged work properly with EF 4.3? Do I just wait on their update?

[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)
Community
  • 1
  • 1
Jemuel Dalino
  • 135
  • 3
  • 12

1 Answers1

1

For me it looks like the initializer is trying to update the EdmMetadata table - at least this is what I infere from:

Devtalk.EF.CodeFirst.DontDropDbJustCreateTablesIfModelChanged`1.SaveModelHashToDatabase(T context, String modelHash, ObjectContext objectContext) 

In EF 4.3 the EdmMeatadata table will not be created (it will be used though if you have one in your database and model did not change - i.e. when you upgrade from 4.1/4.2 to 4.3+ - for more details see: http://blog.oneunicorn.com/2012/01/13/ef-4-3-beta-1-what-happened-to-that-edmmetadata-table/)

In 4.3 world you want to use migrations if your model changes and you need to update the database but don't want to actually delete and recreate it. Take a look at this walkthorugh: http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-code-based-migrations-walkthrough.aspx

Pawel
  • 31,342
  • 4
  • 73
  • 104
  • 2
    Actually just found this thread on SO: http://stackoverflow.com/questions/4031431/entity-framework-ctp-4-code-first-custom-database-initializer where you can see the source of the initializer. It is trying to use the EdmMetadata table so I would think it is not really compatible with EF 4.3+ – Pawel Apr 08 '12 at 03:38
  • 1
    Thank you! Appharbor needs to update their guide for EF 4.3 deployment :D – Jemuel Dalino Apr 08 '12 at 05:52