Reputation: 3380
I have project that works with SQL server. In Models
directory I have migrtions files like as one:
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?
Upvotes: 10
Views: 27032
Reputation: 4163
You should open the Nuget Management Console and type update-database
command with migration name, and additional parameters if they are needed. 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.
Upvotes: 12