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


C# MigrationBuilder.RenameTable方法代码示例

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


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

示例1: Up

 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.RenameTable(
         name: "PropertyChange",
         newName: "property_changes");
     migrationBuilder.RenameTable(
         name: "ModelChange",
         newName: "model_changes");
 }
开发者ID:JOndik,项目名称:SmallTEAmsHelper,代码行数:9,代码来源:20151109223017_schemaMigration4.cs

示例2: Up

 public override void Up(MigrationBuilder migration)
 {
     migration.DropForeignKey(name: "FK_Registration_Member_MemberId", table: "Registration");
     migration.DropColumn(name: "MemberId", table: "Registration");
     migration.DropTable("Member");
     migration.AddColumn(
         name: "UserId",
         table: "Registration",
         type: "nvarchar(450)",
         nullable: true);
     migration.RenameTable(
         name: "AspNetUsers",
         newName: "Users");
     migration.AddColumn(
         name: "Name",
         table: "Users",
         type: "nvarchar(100)",
         nullable: true);
     migration.AddForeignKey(
         name: "FK_Registration_ApplicationUser_UserId",
         table: "Registration",
         column: "UserId",
         referencedTable: "Users",
         referencedColumn: "Id");
 }
开发者ID:cabarney,项目名称:MvcNextGen,代码行数:25,代码来源:20150901212837_MergeMemberIntoUser.cs

示例3: Up

        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_CourseAssignment_Instructor_InstructorID",
                table: "CourseAssignment");

            migrationBuilder.DropForeignKey(
                name: "FK_Department_Instructor_InstructorID",
                table: "Department");

            migrationBuilder.DropForeignKey(
                name: "FK_Enrollment_Student_StudentID",
                table: "Enrollment");

            migrationBuilder.DropIndex(name: "IX_Enrollment_StudentID", table: "Enrollment");

            migrationBuilder.RenameTable(name: "Instructor", newName: "Person");
            migrationBuilder.AddColumn<DateTime>(name: "EnrollmentDate", table: "Person", nullable: true);
            migrationBuilder.AddColumn<string>(name: "Discriminator", table: "Person", nullable: false, maxLength: 128, defaultValue: "Instructor");
            migrationBuilder.AlterColumn<DateTime>(name: "HireDate", table: "Person", nullable: true);
            migrationBuilder.AddColumn<int>(name: "OldId", table: "Person", nullable: true);

            // Copy existing Student data into new Person table.
            migrationBuilder.Sql("INSERT INTO dbo.Person (LastName, FirstName, HireDate, EnrollmentDate, Discriminator, OldId) SELECT LastName, FirstName, null AS HireDate, EnrollmentDate, 'Student' AS Discriminator, ID AS OldId FROM dbo.Student");
            // Fix up existing relationships to match new PK's.
            migrationBuilder.Sql("UPDATE dbo.Enrollment SET StudentId = (SELECT ID FROM dbo.Person WHERE OldId = Enrollment.StudentId AND Discriminator = 'Student')");

            // Remove temporary key
            migrationBuilder.DropColumn(name: "OldID", table: "Person");

            migrationBuilder.DropTable(
                name: "Student");

            migrationBuilder.AddForeignKey(
                name: "FK_Enrollment_Person_StudentID",
                table: "Enrollment",
                column: "StudentID",
                principalTable: "Person",
                principalColumn: "ID",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.CreateIndex(
                 name: "IX_Enrollment_StudentID",
                 table: "Enrollment",
                 column: "StudentID");
        }
开发者ID:MaherJendoubi,项目名称:Docs,代码行数:46,代码来源:20160914172138_Inheritance.cs

示例4: 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.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);
     migrationBuilder.RenameTable(
         name: "Votos",
         newName: "Voto");
 }
开发者ID:alebanzas,项目名称:DevDayCompete,代码行数:46,代码来源:20151206013424_Votos.cs

示例5: Down

 public override void Down(MigrationBuilder migration)
 {
     migration.DropForeignKey(name: "FK_Registration_ApplicationUser_UserId", table: "Registration");
     migration.DropColumn(name: "UserId", table: "Registration");
     migration.DropColumn(name: "Name", table: "Users");
     migration.CreateTable(
         name: "Member",
         columns: table => new
         {
             Id = table.Column(type: "int", nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", "IdentityColumn"),
             Email = table.Column(type: "nvarchar(max)", nullable: true),
             Name = table.Column(type: "nvarchar(100)", nullable: true),
             UserId = table.Column(type: "nvarchar(450)", nullable: true)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Member", x => x.Id);
             table.ForeignKey(
                 name: "FK_Member_ApplicationUser_UserId",
                 columns: x => x.UserId,
                 referencedTable: "AspNetUsers",
                 referencedColumn: "Id");
         });
     migration.AddColumn(
         name: "MemberId",
         table: "Registration",
         type: "int",
         nullable: true);
     migration.AddForeignKey(
         name: "FK_Registration_Member_MemberId",
         table: "Registration",
         column: "MemberId",
         referencedTable: "Member",
         referencedColumn: "Id");
     migration.RenameTable(
         name: "Users",
         newName: "AspNetUsers");
 }
开发者ID:cabarney,项目名称:MvcNextGen,代码行数:39,代码来源:20150901212837_MergeMemberIntoUser.cs

示例6: RenameTable_adds_operation

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

            builder.RenameTable("dbo.MyTable", "MyTable2");

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

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

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

示例7: Down

 protected override void Down(MigrationBuilder migrationBuilder)
     => migrationBuilder.RenameTable(
         name: "Table2",
         newName: "Table1");
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:4,代码来源:MigrationsFixtureBase.cs

示例8: Up

 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.RenameTable(
         name: "Table1",
         newName: "Table2");
 }
开发者ID:rbenhassine2,项目名称:EntityFramework,代码行数:6,代码来源:MigrationsFixtureBase.cs


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