本文整理汇总了C#中MigrationBuilder类的典型用法代码示例。如果您正苦于以下问题:C# MigrationBuilder类的具体用法?C# MigrationBuilder怎么用?C# MigrationBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MigrationBuilder类属于命名空间,在下文中一共展示了MigrationBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Category",
columns: table => new
{
CategoryId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
CategoryName = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Category", x => x.CategoryId);
});
migrationBuilder.CreateTable(
name: "Product",
columns: table => new
{
ProductId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
CategoryId = table.Column<int>(nullable: false),
Price = table.Column<int>(nullable: false),
ProductName = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Product", x => x.ProductId);
table.ForeignKey(
name: "FK_Product_Category_CategoryId",
column: x => x.CategoryId,
principalTable: "Category",
principalColumn: "CategoryId",
onDelete: ReferentialAction.Cascade);
});
}
示例2: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Products_ProductsWithMaintenance_MaintenanceId",
table: "Products");
migrationBuilder.DropIndex(
name: "IX_Products_MaintenanceId",
table: "Products");
migrationBuilder.DropColumn(
name: "MaintenanceId",
table: "Products");
migrationBuilder.AddColumn<int>(
name: "ProductId",
table: "ProductsWithMaintenance",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_ProductsWithMaintenance_ProductId",
table: "ProductsWithMaintenance",
column: "ProductId",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_ProductsWithMaintenance_Products_ProductId",
table: "ProductsWithMaintenance",
column: "ProductId",
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
开发者ID:MvcControlsToolkit,项目名称:MvcControlsToolkit.ControlsCore,代码行数:34,代码来源:20161014131620_business5.cs
示例3: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "PrivacyPolicyUrl",
table: "Organization",
nullable: true);
}
示例4: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "cs_Currency",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "newid()"),
Code = table.Column<string>(nullable: false),
CultureCode = table.Column<string>(nullable: false),
Title = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_cs_Currency", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_cs_Currency_Code",
table: "cs_Currency",
column: "Code");
migrationBuilder.CreateIndex(
name: "IX_cs_Currency_CultureCode",
table: "cs_Currency",
column: "CultureCode");
}
示例5: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Resource_ResourceType_ResourceTypeId", table: "Resource");
migrationBuilder.DropForeignKey(name: "FK_Resource_Supplier_SupplierId", table: "Resource");
migrationBuilder.DropForeignKey(name: "FK_Supplier_Address_AddressId", table: "Supplier");
migrationBuilder.AddForeignKey(
name: "FK_Resource_ResourceType_ResourceTypeId",
table: "Resource",
column: "ResourceTypeId",
principalTable: "ResourceType",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Resource_Supplier_SupplierId",
table: "Resource",
column: "SupplierId",
principalTable: "Supplier",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Supplier_Address_AddressId",
table: "Supplier",
column: "AddressId",
principalTable: "Address",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例6: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("PostTag");
migrationBuilder.DropTable("Post");
migrationBuilder.DropTable("Tag");
migrationBuilder.DropTable("Category");
}
示例7: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Blog",
columns: table => new
{
BlogId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Url = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Blog", x => x.BlogId);
});
migrationBuilder.CreateTable(
name: "Post",
columns: table => new
{
PostId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
BlogId = table.Column<int>(nullable: false),
Content = table.Column<string>(nullable: true),
Title = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Post", x => x.PostId);
table.ForeignKey(
name: "FK_Post_Blog_BlogId",
column: x => x.BlogId,
principalTable: "Blog",
principalColumn: "BlogId",
onDelete: ReferentialAction.Cascade);
});
}
示例8: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Employee",
columns: table => new
{
EmpId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Age = table.Column<int>(nullable: false),
FirstName = table.Column<string>(nullable: false),
LastName = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EmployeeEntity", x => x.EmpId);
});
migrationBuilder.CreateTable(
name: "Job",
columns: table => new
{
JobId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
JobDesc = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_JobEntity", x => x.JobId);
});
}
示例9: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "DisplayName",
table: "TestClasses",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Commits_ProjectId",
table: "Commits",
column: "ProjectId");
migrationBuilder.CreateIndex(
name: "IX_Commits_UserId",
table: "Commits",
column: "UserId");
migrationBuilder.AddForeignKey(
name: "FK_Commits_Projects_ProjectId",
table: "Commits",
column: "ProjectId",
principalTable: "Projects",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Commits_Users_UserId",
table: "Commits",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例10: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema("mab");
migrationBuilder.CreateTable(
name: "MicroAggression",
schema: "mab",
columns: table => new
{
Aggression = table.Column<string>(nullable: false),
Aggressiveness = table.Column<int>(nullable: false),
Created = table.Column<DateTime>(nullable: false),
_Alternatives = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MicroAggression", x => x.Aggression);
});
migrationBuilder.CreateTable(
name: "Offense",
schema: "mab",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Offenses = table.Column<int>(nullable: false),
User = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Offense", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Correction",
schema: "mab",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Created = table.Column<DateTime>(nullable: false),
MicroAggressionId = table.Column<string>(nullable: true),
OffenseId = table.Column<Guid>(nullable: false),
Tweet = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Correction", x => x.Id);
table.ForeignKey(
name: "FK_Correction_MicroAggression_MicroAggressionId",
column: x => x.MicroAggressionId,
principalSchema: "mab",
principalTable: "MicroAggression",
principalColumn: "Aggression",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Correction_Offense_OffenseId",
column: x => x.OffenseId,
principalSchema: "mab",
principalTable: "Offense",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
}
示例11: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Name",
table: "Uploads",
nullable: true);
}
示例12: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "LastName",
table: "Follower",
isNullable: true);
}
示例13: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "ClassSubmissionType",
table: "Questions",
nullable: true);
}
示例14: Up
public override void Up(MigrationBuilder migration)
{
migration.CreateTable(
name: "Categoria",
columns: table => new
{
CategoriaID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:ValueGeneration", "Identity"),
Descripcion = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Categoria", x => x.CategoriaID);
});
migration.AddColumn(
name: "CategoriaID",
table: "Cursos",
type: "int",
nullable: true);
migration.AddForeignKey(
name: "FK_Cursos_Categoria_CategoriaID",
table: "Cursos",
column: "CategoriaID",
referencedTable: "Categoria",
referencedColumn: "CategoriaID");
}
示例15: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("ActivitySignup");
migrationBuilder.DropTable("ActivitySkill");
migrationBuilder.DropTable("CampaignImpact");
migrationBuilder.DropTable("CampaignSponsors");
migrationBuilder.DropTable("Resource");
migrationBuilder.DropTable("TaskSignup");
migrationBuilder.DropTable("TaskSkill");
migrationBuilder.DropTable("UserSkill");
migrationBuilder.DropTable("AspNetRoleClaims");
migrationBuilder.DropTable("AspNetUserClaims");
migrationBuilder.DropTable("AspNetUserLogins");
migrationBuilder.DropTable("AspNetUserRoles");
migrationBuilder.DropTable("CampaignImpactType");
migrationBuilder.DropTable("AllReadyTask");
migrationBuilder.DropTable("Skill");
migrationBuilder.DropTable("AspNetRoles");
migrationBuilder.DropTable("Activity");
migrationBuilder.DropTable("Campaign");
migrationBuilder.DropTable("Location");
migrationBuilder.DropTable("AspNetUsers");
migrationBuilder.DropTable("PostalCodeGeo");
migrationBuilder.DropTable("Tenant");
}