本文整理汇总了C#中MigrationBuilder.AlterColumn方法的典型用法代码示例。如果您正苦于以下问题:C# MigrationBuilder.AlterColumn方法的具体用法?C# MigrationBuilder.AlterColumn怎么用?C# MigrationBuilder.AlterColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MigrationBuilder
的用法示例。
在下文中一共展示了MigrationBuilder.AlterColumn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Category_Article", table: "Article");
migrationBuilder.AlterColumn<string>(
name: "Url",
table: "Section",
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "Title",
table: "Section",
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "Url",
table: "Category",
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "Title",
table: "Category",
nullable: false);
migrationBuilder.AddForeignKey(
name: "FK_Category_Article",
table: "Article",
column: "CategoryId",
principalTable: "Category",
principalColumn: "CategoryId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Section_Category",
table: "Category",
column: "SectionId",
principalTable: "Section",
principalColumn: "SectionId",
onDelete: ReferentialAction.Cascade);
}
示例2: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Prize_Shop_ShopId", table: "Prize");
migrationBuilder.DropForeignKey(name: "FK_Puzzle_Shop_ShopId", table: "Puzzle");
migrationBuilder.AlterColumn<TimeSpan>(
name: "Opening2",
table: "OpeningHours",
nullable: true);
migrationBuilder.AlterColumn<TimeSpan>(
name: "Opening1",
table: "OpeningHours",
nullable: true);
migrationBuilder.AlterColumn<TimeSpan>(
name: "Closing2",
table: "OpeningHours",
nullable: true);
migrationBuilder.AlterColumn<TimeSpan>(
name: "Closing1",
table: "OpeningHours",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Prize_Shop_ShopId",
table: "Prize",
column: "ShopId",
principalTable: "Shop",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Puzzle_Shop_ShopId",
table: "Puzzle",
column: "ShopId",
principalTable: "Shop",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
示例3: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<bool>(
name: "IsRecurring",
schema: "dbo",
table: "Events",
isNullable: false,
defaultValue: false);
migrationBuilder.AlterColumn<int>(
name: "ContactId",
schema: "dbo",
table: "Events",
isNullable: true);
migrationBuilder.AddColumn<int>(
name: "ContactId1",
schema: "dbo",
table: "Events",
isNullable: false,
defaultValue: 0);
migrationBuilder.AddForeignKey(
name: "FK_ChurchEvent_ChurchMember_ContactId1",
schema: "dbo",
table: "Events",
column: "ContactId1",
principalSchema: "dbo",
principalTable: "Members",
principalColumn: "Id");
}
示例4: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserLogins",
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserClaims",
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "RoleId",
table: "AspNetRoleClaims",
nullable: false);
migrationBuilder.AddColumn<string>(
name: "Discriminator",
table: "AspNetRoles",
nullable: false,
defaultValue: "");
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例5: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Products_ProductCategories_ProjectCategoryProductCategoryId",
table: "Products");
migrationBuilder.AlterColumn<int>(
name: "ProjectCategoryProductCategoryId",
table: "Products",
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "ProductName",
table: "Products",
maxLength: 100,
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "ProductDescription",
table: "Products",
maxLength: 1000,
nullable: false);
migrationBuilder.AddForeignKey(
name: "FK_Products_ProductCategories_ProjectCategoryProductCategoryId",
table: "Products",
column: "ProjectCategoryProductCategoryId",
principalTable: "ProductCategories",
principalColumn: "ProductCategoryId",
onDelete: ReferentialAction.Cascade);
}
示例6: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_PriceHistory_Stock_StockId", table: "PriceHistory");
migrationBuilder.DropForeignKey(name: "FK_Txn_Stock_StockId", table: "Txn");
migrationBuilder.AlterColumn<decimal>(
name: "Open",
table: "PriceHistory",
nullable: false);
migrationBuilder.AlterColumn<decimal>(
name: "Low",
table: "PriceHistory",
nullable: false);
migrationBuilder.AlterColumn<decimal>(
name: "High",
table: "PriceHistory",
nullable: false);
migrationBuilder.AlterColumn<decimal>(
name: "Close",
table: "PriceHistory",
nullable: false);
migrationBuilder.AddForeignKey(
name: "FK_PriceHistory_Stock_StockId",
table: "PriceHistory",
column: "StockId",
principalTable: "Stock",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Txn_Stock_StockId",
table: "Txn",
column: "StockId",
principalTable: "Stock",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
示例7: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "LastUpdated",
table: "Projects",
nullable: false,
defaultValueSql: "GetDate()");
migrationBuilder.AddColumn<DateTime>(
name: "LastUpdated",
table: "Products",
nullable: false,
defaultValueSql: "GetDate()");
migrationBuilder.AlterColumn<DateTime>(
name: "LastUpdated",
table: "WorkItems",
nullable: false,
defaultValueSql: "GetDate()");
migrationBuilder.AlterColumn<DateTime>(
name: "LastUpdated",
table: "ProductCategories",
nullable: false,
defaultValueSql: "GetDate()");
}
示例8: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.DropColumn(name: "City", table: "AspNetUsers");
migrationBuilder.DropColumn(name: "State", table: "AspNetUsers");
migrationBuilder.DropTable("ToDo");
migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserLogins",
nullable: true);
migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserClaims",
nullable: true);
migrationBuilder.AlterColumn<string>(
name: "RoleId",
table: "AspNetRoleClaims",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
示例9: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "Weight",
table: "Player",
nullable: true);
migrationBuilder.AlterColumn<int>(
name: "Height",
table: "Player",
nullable: true);
}
示例10: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "LastName",
table: "Player",
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "FirstName",
table: "Player",
nullable: false);
}
示例11: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "LastName",
table: "Student",
nullable: true);
migrationBuilder.AlterColumn<string>(
name: "FirstMidName",
table: "Student",
nullable: true);
}
示例12: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_ChirpPost_ChirpUser_UserId", table: "ChirpPost");
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ChirpUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ChirpUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ChirpUser_UserId", table: "AspNetUserRoles");
migrationBuilder.DropColumn(name: "HasProfilePicture", table: "AspNetUsers");
migrationBuilder.AlterColumn<int>(
name: "UserId",
table: "ChirpPost",
nullable: false);
migrationBuilder.AlterColumn<DateTime>(
name: "PostTime",
table: "ChirpPost",
nullable: false);
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ChirpUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ChirpUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ChirpUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
示例13: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "StartTime",
table: "TemperatureSettings",
nullable: true);
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "EndTime",
table: "TemperatureSettings",
nullable: true);
}
示例14: Up
public override void Up(MigrationBuilder migration)
{
migration.AlterColumn(
name: "DireccionId",
table: "Usuario",
type: "int",
nullable: true);
migration.AlterColumn(
name: "TelefonoId",
table: "Usuario",
type: "int",
nullable: true);
}
示例15: Up
public override void Up(MigrationBuilder migration)
{
migration.AlterColumn(
name: "Latitude",
table: "PhoneSpotting",
type: "float",
nullable: false);
migration.AlterColumn(
name: "Longitude",
table: "PhoneSpotting",
type: "float",
nullable: false);
}