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


C# MigrationBuilder.DropPrimaryKey方法代码示例

本文整理汇总了C#中MigrationBuilder.DropPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:C# MigrationBuilder.DropPrimaryKey方法的具体用法?C# MigrationBuilder.DropPrimaryKey怎么用?C# MigrationBuilder.DropPrimaryKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MigrationBuilder的用法示例。


在下文中一共展示了MigrationBuilder.DropPrimaryKey方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Down

 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Translation_Content_ContentId", table: "Translation");
     migrationBuilder.DropPrimaryKey(name: "PK_Content", table: "Content");
     migrationBuilder.DropColumn(name: "Id", table: "Content");
     migrationBuilder.AddColumn<Guid>(
         name: "ContentContentGuid",
         table: "Translation",
         nullable: true);
     migrationBuilder.AddColumn<Guid>(
         name: "ContentGuid",
         table: "Content",
         nullable: false,
         defaultValueSql: "newsequentialid()");
     migrationBuilder.AddPrimaryKey(
         name: "PK_Content",
         table: "Content",
         column: "ContentGuid");
     migrationBuilder.AddForeignKey(
         name: "FK_Translation_Content_ContentContentGuid",
         table: "Translation",
         column: "ContentContentGuid",
         principalTable: "Content",
         principalColumn: "ContentGuid",
         onDelete: ReferentialAction.Restrict);
 }
开发者ID:nettsundere,项目名称:PersonalWebsite,代码行数:26,代码来源:20151128025750_ReplaceGuidWithIdForContentsAndTranslations.cs

示例2: Up

 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropPrimaryKey(name: "PK_LpaUserClaim", table: "UserClaims");
     migrationBuilder.AddPrimaryKey(
         name: "PK_LpaUserClaim",
         table: "UserClaims",
         columns: new[] { "UserId", "ClaimId" })
         .Annotation("SqlServer:Clustered", true);
 }
开发者ID:nteague22,项目名称:LPA-Site,代码行数:9,代码来源:20151005050515_FixedMtoMAuth.cs

示例3: Up

 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_MasterToRole_Role_RoleId", table: "MasterToRole");
     migrationBuilder.DropPrimaryKey(name: "PK_MasterToRole", table: "MasterToRole");
     migrationBuilder.DropColumn(name: "RoleId", table: "MasterToRole");
     migrationBuilder.DropTable("Role");
     migrationBuilder.AlterColumn<string>(
         name: "IdentityRoleId",
         table: "MasterToRole",
         nullable: false);
     migrationBuilder.AddPrimaryKey(
         name: "PK_MasterToRole",
         table: "MasterToRole",
         columns: new[] { "IdentityRoleId", "MasterID" });
 }
开发者ID:DmitryPP,项目名称:ASPNET5,代码行数:15,代码来源:20151111204851_m3.cs

示例4: Up

 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropPrimaryKey(name: "PK_IdentityRole", table: "AspNetRoles");
     migrationBuilder.AddPrimaryKey(
         name: "PK_ApplicationRole",
         table: "AspNetRoles",
         column: "Id");
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityRoleClaim<string>_ApplicationRole_RoleId",
         table: "AspNetRoleClaims",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id");
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserRole<string>_ApplicationRole_RoleId",
         table: "AspNetUserRoles",
         column: "RoleId",
         principalTable: "AspNetRoles",
         principalColumn: "Id");
 }
开发者ID:HostedSolutions,项目名称:TFSToolbox,代码行数:22,代码来源:20151025145959_Initial2.cs

示例5: Up

 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_Translation_Content_ContentContentGuid", table: "Translation");
     migrationBuilder.DropPrimaryKey(name: "PK_Content", table: "Content");
     migrationBuilder.DropColumn(name: "ContentContentGuid", table: "Translation");
     migrationBuilder.DropColumn(name: "ContentGuid", table: "Content");
     migrationBuilder.AddColumn<int>(
         name: "Id",
         table: "Content",
         nullable: false)
         .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
     migrationBuilder.AddPrimaryKey(
         name: "PK_Content",
         table: "Content",
         column: "Id");
     migrationBuilder.AddForeignKey(
         name: "FK_Translation_Content_ContentId",
         table: "Translation",
         column: "ContentId",
         principalTable: "Content",
         principalColumn: "Id",
         onDelete: ReferentialAction.Cascade);
 }
开发者ID:nettsundere,项目名称:PersonalWebsite,代码行数:23,代码来源:20151128025750_ReplaceGuidWithIdForContentsAndTranslations.cs

示例6: Down

 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropPrimaryKey(name: "PK_MasterToRole", table: "MasterToRole");
     migrationBuilder.CreateTable(
         name: "Role",
         columns: table => new
         {
             Id = table.Column<string>(nullable: false),
             ConcurrencyStamp = table.Column<string>(nullable: true),
             Name = table.Column<string>(nullable: true),
             NormalizedName = table.Column<string>(nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Role", x => x.Id);
         });
     migrationBuilder.AlterColumn<string>(
         name: "IdentityRoleId",
         table: "MasterToRole",
         nullable: true);
     migrationBuilder.AddColumn<string>(
         name: "RoleId",
         table: "MasterToRole",
         nullable: false,
         defaultValue: "");
     migrationBuilder.AddPrimaryKey(
         name: "PK_MasterToRole",
         table: "MasterToRole",
         columns: new[] { "RoleId", "MasterID" });
     migrationBuilder.AddForeignKey(
         name: "FK_MasterToRole_Role_RoleId",
         table: "MasterToRole",
         column: "RoleId",
         principalTable: "Role",
         principalColumn: "Id");
 }
开发者ID:DmitryPP,项目名称:ASPNET5,代码行数:36,代码来源:20151111204851_m3.cs

示例7: DropPrimaryKey_adds_operation

        public void DropPrimaryKey_adds_operation()
        {
            var builder = new MigrationBuilder();

            builder.DropPrimaryKey("dbo.MyTable", "MyPK");

            Assert.Equal(1, builder.Operations.Count);
            Assert.IsType<DropPrimaryKeyOperation>(builder.Operations[0]);

            var operation = (DropPrimaryKeyOperation)builder.Operations[0];

            Assert.Equal("dbo.MyTable", operation.TableName);
            Assert.Equal("MyPK", operation.PrimaryKeyName);
        }
开发者ID:Nyaoso,项目名称:EntityFramework,代码行数:14,代码来源:MigrationBuilderTest.cs

示例8: Down

 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropPrimaryKey(name: "PK_LpaUserClaim", table: "UserClaims");
 }
开发者ID:nteague22,项目名称:LPA-Site,代码行数:4,代码来源:20151005050515_FixedMtoMAuth.cs


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