[英]How to run migration in C#.NET project?
I have project that works with SQL server. 我有与SQL服务器一起使用的项目。 In
Models
directory I have migrtions files like as one: 在
Models
目录中,我有一个像以下一样的迁移文件:
public partial class UserData : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.confirmation_code",
c => new
{
sys_id = c.Long(nullable: false, identity: true),
resource_id = c.Guid(nullable: false),
code = c.String(maxLength: 64),
user_id = c.Long(nullable: false),
id = c.Guid(nullable: false),
edit_date = c.DateTime(nullable: false),
})
.PrimaryKey(t => t.sys_id)
.ForeignKey("dbo.user", t => t.user_id, cascadeDelete: true)
.Index(t => t.user_id);
....
For development I use VisualStudio, how to run all migration to deploy? 对于开发我使用VisualStudio,如何运行所有迁移部署?
You should open the Nuget Management Console and type update-database
command with migration name, and additional parameters if they are needed. 您应该打开Nuget管理控制台并使用迁移名称键入
update-database
命令,并在需要时输入其他参数。 Depending on your setup you might need to provide connection string name and/or project where they are located. 根据您的设置,您可能需要提供连接字符串名称和/或项目所在的位置。
More on this: Entity Framework Code First Migrations . 更多相关信息: 实体框架代码首次迁移 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.