开启codefirst迁移命令:Enable-Migrations -ContextTypeName BlogEntitiesBlogEntities(上下文,继承DbContext的那个类)更新数据库命令
开启codefirst迁移命令:
Enable-Migrations -ContextTypeName BlogEntities
BlogEntities(上下文,继承DbContext的那个类)
更新数据库命令:
Update-Database -Verbose
新增变更类文件命令:
Add-Migration AddBolg
AddBolg(生成的文件名)
Add-Migration AddBolg-IgnoreChanges:对现有数据库进行迁移
自动数据迁移:
将Configuration的AutomaticMigrationsEnabled设置为true
当设置自动数据迁移之后,放模型变更只需要执行Update-Database -Verbose命令
注意:模型有删减的话需要先执行Add-Migration命令再执行Update-Database -Verbose命令
注意,当执行Enable-Migrations -ContextTypeName BlogEntities命令是报如下错误时需要使用NuGet添加EntityFramework:
--结束END--
本文标题: EF数据库迁移
本文链接: https://www.lsjlt.com/news/42962.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-28
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0