我在Internet上找不到解決我的問題的方法。如何在asp net mvc中運行遷移3
我有一個項目ASP淨MVC 3,我有一個數據庫,我已經從數據庫中的類類似的實體:
public class Product : Entity
{
[Required(ErrorMessage = "Error!")]
public virtual string Name { get; set; }
[Required(ErrorMessage = "Error!")]
public virtual int Age { get; set; }
}
在我的項目,我想使用的遷移。在項目中,我添加了庫FluentMigrator,創建了下面的類(這是一個測試類與測試表):
[Migration(1)]
public class Step1 : Migration
{
public override void Up()
{
#region Create Tables
Create.Table("Products").InSchema("dbo")
.WithColumn("ProductId").AsInt32().Identity().NotNullable().PrimaryKey()
.WithColumn("Name").AsString(255).Nullable()
.WithColumn("Age").AsInt32().Nullable();
#endregion
this.Execute.Script("test.sql");
}
public override void Down()
{
#region Delete Tables
Delete.Table("Products").InSchema("dbo");
#endregion
}
}
也是在我的解決方案我創建的文件 - 「TEST.SQL」。該文件包含以下代碼:
INSERT INTO [Products] ([Name],[Age])
VALUES ('test12', 1111)
請告訴我,我怎麼能運行在我的項目的遷移,從文件「TEST.SQL」的代碼添加到表中「產品」? 對不起,我的英語。
http://msdn.microsoft.com/en-us/data/jj591621.aspx#generating – SLaks