国产老熟女高潮毛片A片仙踪林,欧美喂奶吃大乳,狠狠爱无码一区二区三区,女神的私人医生动漫免费阅读

新聞建站cms系統(tǒng)、政府cms系統(tǒng)定制開發(fā)

廣州網(wǎng)站建設公司-閱速公司

asp.net新聞發(fā)布系統(tǒng)、報紙數(shù)字報系統(tǒng)方案
/
http://www.tjsimaide.com/
廣州網(wǎng)站建設公司
您當前位置:首頁>ASP.NET MVC

ASP.NET MVC

如何在asp.net mvc 3.0使用Nuget更新數(shù)據(jù)庫?

發(fā)布時間:2014/1/10 11:32:32  作者:Admin  閱讀:574  

廣告:

asp.net mvc3.0我們就需要更新數(shù)據(jù)庫,方法是:

1.安裝VS的Nuget。打開Nuget控制臺,輸入Enable-Migrations啟用數(shù)據(jù)庫遷移。如果已經(jīng)啟用,控制臺會提示“Migrations have already been enabled in project '***'. To overwrite the existing migrations configuration, use the -Force parameter.”

2.標記遷移點,輸入Add-Migration ***,星號為遷移點名稱,可自定義。

3.輸入Update-Database完成更新。

此時再執(zhí)行程序,則不會再出現(xiàn)報錯,數(shù)據(jù)庫也更新完畢了。如果想回退到某一次的遷移點,只需要在Nuget控制臺中輸入 Update-Database –TargetMigration:"***" 星號為遷移點名稱。另外可以通過Script參數(shù)生成腳本,例如Update-Database -Script -SourceMigration:"**" -TargetMigration:"**" 這樣就會生成一個sql腳本而不是直接更新數(shù)據(jù)庫。

當然,如果覺得操作控制臺的指令太多不方便,可以使用自動遷移功能。方法如下:

1.打開 Migrations文件夾下的Configuration.cs,修改代碼為

public Configuration()

{

AutomaticMigrationsEnabled = true;

}

2.如果需要更新數(shù)據(jù)庫,只需要在Nuget控制臺輸入Update-Database -Verbose即可,如果提示“Automatic migration was not applied because it would result in data loss”(不能自動遷移,會導致數(shù)據(jù)丟失) ,則在Update-Database 后面加 -Force參數(shù)即可。注意,這樣并不會引起數(shù)據(jù)丟失。

PM> Update-Database -Force

Specify the '-Verbose' flag to view the SQL statements being applied to the target database.

No migrations configuration type was found in the assembly 'TopWin.Etone.Web'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).

 

廣告:

相關文章
asp.net mvc
Nuget
cms新聞系統(tǒng)購買咨詢
掃描關注 廣州閱速軟件科技有限公司
掃描關注 廣州閱速科技
主站蜘蛛池模板: 平武县| 松阳县| 蕲春县| 舞阳县| 长泰县| 平凉市| 丰顺县| 刚察县| 连南| 阿荣旗| 佛教| 乌拉特中旗| 博客| 外汇| 皮山县| 潞城市| 商城县| 宝兴县| 大理市| 黑水县| 乐山市| 汶川县| 宝丰县| 偃师市| 长乐市| 新安县| 溧阳市| 朝阳市| 含山县| 互助| 哈巴河县| 镇坪县| 安仁县| 奉贤区| 上林县| 当阳市| 二连浩特市| 三都| 瑞丽市| 济阳县| 阿城市|