irc-netcore-api/IRaCIS.Core.Test/CodeFirstTest/CodeFirst使用说明

32 lines
1000 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#参考学习文档
https://www.cnblogs.com/cqpanda/p/16815263.html
# dotnet ef migrations add 本地迁移名字 -p 项目名 -c 数据库上下文名 -o 迁移文件生成目录
1、生成迁移文件
dotnet ef migrations add Initial -p IRaCIS.Core.Test -c IRCContext -o CodeFirstTest/MSSQL/Migrations
2、撤销刚才生成的迁移文件未更新到数据库的
dotnet ef migrations remove -p IRaCIS.Core.Test -c IRCContext
3、将迁移文件更新到数据库
dotnet ef database update -p IRaCIS.Core.Test -c IRCContext
4、查看已有迁移
dotnet ef migrations list -p IRaCIS.Core.Test -c IRCContext
5、撤销某次更新到数据库的迁移自动执行down 方法)
dotnet ef database update 某次迁移的前一次迁移名称 -p IRaCIS.Core.Test -c IRCContext
dotnet ef migrations add RemoveForeignKey -p IRaCIS.Core.Test -c IRCContext -o CodeFirstTest/MSSQL/Migrations
PGSQL 指定
dotnet ef migrations add testSTR -p IRaCIS.Core.Test -c PGContext -o CodeFirstTest/PGSQL/Migrations
dotnet ef migrations remove -p IRaCIS.Core.Test -c PGContext