首页 新闻 搜索 专区 学院

mvc3原来写的增删改现在运行报错,大家看看是怎么回事

0
悬赏园豆:10 [待解决问题]

“/”应用程序中的服务器错误。

The model backing the 'HjsyEntities' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.InvalidOperationException: The model backing the 'HjsyEntities' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.

源错误:

行 16:         public ActionResult Index()
行 17:         {
行 18:             var paras = db.TParas.ToList();
行 19:             return View(paras);
行 20:         }


源文件: E:\何杰摄影\hjsy\Controllers\TParaController.cs    行: 18

堆栈跟踪:

[InvalidOperationException: The model backing the 'HjsyEntities' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.]
   System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context) +443
   System.Data.Entity.Internal.<>c__DisplayClass5.<PerformDatabaseInitialization>b__3() +59
   System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +101
   System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +260
   System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) +31
   System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +147
   System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +276
   System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +112
   System.Data.Entity.Internal.InternalContext.Initialize() +41
   System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +34
   System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +148
   System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() +33
   System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() +91
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +315
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
   hjsy.Controllers.TParaController.Index() in E:\何杰摄影\hjsy\Controllers\TParaController.cs:18
   lambda_method(Closure , ControllerBase , Object[] ) +96
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
   System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
   System.Web.Mvc.Controller.ExecuteCore() +116
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184



版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.1

问题补充:

经查:

删掉或重命名EdmMetadata库即可,前期可自动生成,后期如何来处理呢,仅仅删除EdmMetadata吗,会不会对系统造成不好的影响?

软冰的主页 软冰 | 初学一级 | 园豆:145
提问于:2011-05-30 00:36
< >
分享
所有回答(2)
0

EF 的Entities 有修改, 所有要删除数据库 让它重新生成一个

如果还有问题 那可能是没有数据的原因

火车叨位去丶 | 园豆:2 (初学一级) | 2011-06-02 16:57
0

如果你用的是MVC3.0,那就要看下Entites中其他的Model,因为每次都会映射全部的Model。

MrCui | 园豆:162 (初学一级) | 2011-08-02 17:36
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册