当前位置: 首页>>代码示例>>C#>>正文


C# MigrationBuilder.AlterColumn方法代码示例

本文整理汇总了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);
 }
开发者ID:sergeyb12345,项目名称:MarketHunter,代码行数:34,代码来源:20151229104238_FkSectionCategory.cs

示例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);
 }
开发者ID:sickpres,项目名称:PuzzleAdv,代码行数:35,代码来源:20160403105925_Puzzle6.cs

示例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");
 }
开发者ID:nteague22,项目名称:Lighthouse.Site,代码行数:28,代码来源:20150928191656_refData.cs

示例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);
 }
开发者ID:longlostbro,项目名称:MinecraftWeb,代码行数:60,代码来源:20160219020402_migrate.cs

示例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);
        }
开发者ID:RossWhitehead,项目名称:SandboxCore,代码行数:31,代码来源:20160828062028_Required.cs

示例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);
 }
开发者ID:isonaj,项目名称:portfolio2,代码行数:35,代码来源:20160221113610_3DecimalPrices.cs

示例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()");
        }
开发者ID:RossWhitehead,项目名称:SandboxCore,代码行数:26,代码来源:20160822185317_AddLastUpdated.cs

示例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);
 }
开发者ID:mperrenoud,项目名称:packt,代码行数:58,代码来源:20160127111720_ToDo_NewProfileFields.cs

示例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);
 }
开发者ID:yvaravko,项目名称:JuveV,代码行数:11,代码来源:20160203193857_PlayerChanges.cs

示例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);
 }
开发者ID:yvaravko,项目名称:JuveV,代码行数:11,代码来源:20160203200714_PlayerFieldsChanges.cs

示例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);
        }
开发者ID:MaherJendoubi,项目名称:Docs,代码行数:12,代码来源:20160727165037_MaxLengthOnNames.cs

示例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);
 }
开发者ID:SteveF92,项目名称:Chirp,代码行数:53,代码来源:20160320093307_ProfilePicture.cs

示例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);
        }
开发者ID:holtsoftware,项目名称:House,代码行数:12,代码来源:20160907145545_ChangedDateTypeForTemperatureSetting.cs

示例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);
 }
开发者ID:CarlosOlivares,项目名称:web,代码行数:13,代码来源:20150823131245_Once.cs

示例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);
 }
开发者ID:jeffa00,项目名称:WinPhoneSpotter01,代码行数:13,代码来源:20150705183526_FixLatLongType.cs


注:本文中的MigrationBuilder.AlterColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。