c# - Changes in Model .NET asp.net MVC4 -
i've created project using steps
create model; create controller model , scaffolding views;
i've tried access, , works fine, i've made changes in model rebuilt , tried run 1 more time, , got error:
{"the model backing 'codingcontext' context has changed since database created. consider using code first migrations update database (http://go.microsoft.com/fwlink/?linkid=238269)."}
this error brings null inner exception
and stack:
at system.data.entity.createdatabaseifnotexists
1.initializedatabase(tcontext context) @ system.data.entity.internal.internalcontext.<>c__displayclass8.<performdatabaseinitialization>b__6() @ system.data.entity.internal.internalcontext.performinitializationaction(action action) @ system.data.entity.internal.internalcontext.performdatabaseinitialization() @ system.data.entity.internal.lazyinternalcontext.<initializedatabase>b__4(internalcontext c) @ system.data.entity.internal.retryaction
1.performaction(tinput input) @ system.data.entity.internal.lazyinternalcontext.initializedatabaseaction(action1 action) @ system.data.entity.internal.lazyinternalcontext.initializedatabase() @ system.data.entity.internal.internalcontext.initialize() @ system.data.entity.internal.internalcontext.getentitysetandbasetypefortype(type entitytype) @ system.data.entity.internal.linq.internalset
1.initialize() @ system.data.entity.internal.linq.internalset1.getenumerator() @ system.data.entity.infrastructure.dbquery
1.system.collections.generic.ienumerable.getenumerator() @ system.collections.generic.list1..ctor(ienumerable
1 collection) @ system.linq.enumerable.tolist[tsource](ienumerable1 source) @ coding.controllers.corcontroller.index() in c:\users\guilherme\documents\visual studio 2012\projects\coding\coding\controllers\corcontroller.cs:line 19 @ lambda_method(closure , controllerbase , object[] ) @ system.web.mvc.actionmethoddispatcher.execute(controllerbase controller, object[] parameters) @ system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary
2 parameters) @ system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary2 parameters) @ system.web.mvc.async.asynccontrolleractioninvoker.invokesynchronousactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary
2 parameters) @ system.web.mvc.async.asynccontrolleractioninvoker.<>c_displayclass42.b_41() @ system.web.mvc.async.asyncresultwrapper.<>c_displayclass81.<beginsynchronous>b__7(iasyncresult _) @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult
1.end() @ system.web.mvc.async.asyncresultwrapper.end[tresult](iasyncresult asyncresult, object tag) @ system.web.mvc.async.asynccontrolleractioninvoker.endinvokeactionmethod(iasyncresult asyncresult) @ system.web.mvc.async.asynccontrolleractioninvoker.<>c_displayclass37.<>c_displayclass39.b_33() @ system.web.mvc.async.asynccontrolleractioninvoker.<>c_displayclass4f.b_49()
i think problem refresing database using new model, can't found command solve problem.
thanks in advance!
if got same problem, got answer friend help, must follow these steps update database:
open package manager console: tools –> library package manager –> package manager console
install entity framework: install-package entityframework
run: enable-migrations
at point i'd got problems, visual studio show me answer, problem of multiple contexts
run: add-migration
then: update-database
and it's done, every change in model, require run these commands!
Comments
Post a Comment