自创建数据库以来,支持“MyContext”上下文的模型已更改。 [英] The model backing the 'MyContext' context has changed since the database was created.

查看:174
本文介绍了自创建数据库以来,支持“MyContext”上下文的模型已更改。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自创建数据库以来,支持'MyContext'上下文的模型已更改。手动删除/更新数据库,或使用IDatabaseInitializer实例调用Database.SetInitializer。例如,DropCreateDatabaseIfModelChanges策略将自动删除并重新创建数据库,并可选择为其添加新数据。

The model backing the 'MyContext' 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.

推荐答案

使用一些步骤更新MVC应用程序数据库

Update MVC application Database with some steps
1. Open Package Manager Console from Tools->Library Package Manager
2.PM> Enable-Migrations -ContextTypeName DatabaseName
Then Make enable true of code migrations
3. AutomaticMigrationsEnabled=true; from Migrations folder of Configuration file
Next run the command in PMC
4. PM> Add-Migration InitialCreate
Next update your database
5. PM> Update-Database -Verbose
or
6. PM> Update-Database -Verbose -Force


这篇关于自创建数据库以来,支持“MyContext”上下文的模型已更改。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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