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


C# MigrationBuilder类代码示例

本文整理汇总了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);
         });
 }
开发者ID:ZhangYueqiu,项目名称:asp5-mvc6-examples,代码行数:35,代码来源:20151210230637_Initial.cs

示例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);
 }
开发者ID:yobenzima,项目名称:allReady,代码行数:7,代码来源:20160625142330_PrivacyPolicyUrl.cs

示例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");
        }
开发者ID:ReinhardHsu,项目名称:cloudscribe,代码行数:26,代码来源:20160612144428_RemoveCurrecncy.cs

示例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);
 }
开发者ID:DevJams,项目名称:HCMC-HCMC.Azure.API,代码行数:27,代码来源:20160126200255_Resource4.cs

示例6: Down

 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropTable("PostTag");
     migrationBuilder.DropTable("Post");
     migrationBuilder.DropTable("Tag");
     migrationBuilder.DropTable("Category");
 }
开发者ID:AlexanderYakshin,项目名称:Blog,代码行数:7,代码来源:20160204094441_Initial.cs

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

示例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);
         });
 }
开发者ID:cgideon,项目名称:EntityFrameworkDemo,代码行数:29,代码来源:20160111170153_MyFirstMigration.cs

示例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);
        }
开发者ID:CSClassroom,项目名称:CSClassroom,代码行数:33,代码来源:20160918231759_Migration9.cs

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

示例11: Down

 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.AddColumn<string>(
         name: "Name",
         table: "Uploads",
         nullable: true);
 }
开发者ID:jmk22,项目名称:FileUpload01,代码行数:7,代码来源:20160111193714_RemoveNameProperty.cs

示例12: Up

 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.AddColumn<string>(
         name: "LastName",
         table: "Follower",
         isNullable: true);
 }
开发者ID:tingvast,项目名称:EF7-Sandbox,代码行数:7,代码来源:20150930135924_v5.cs

示例13: Down

 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.AlterColumn<int>(
         name: "ClassSubmissionType",
         table: "Questions",
         nullable: true);
 }
开发者ID:CSClassroom,项目名称:CSClassroom,代码行数:7,代码来源:20160924000038_Migration16.cs

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

示例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");
 }
开发者ID:BredStik,项目名称:allReady,代码行数:25,代码来源:20151107231334_InitialDatabase.cs


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