• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MigrationBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



MigrationBuilder类属于命名空间,在下文中一共展示了MigrationBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Up

        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Toast",
                columns: table => new
                {
                    ToastId = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    BeerId = table.Column<int>(nullable: false),
                    DateTime = table.Column<DateTime>(nullable: false),
                    Description = table.Column<string>(nullable: true),
                    Grade = table.Column<double>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Toast", x => x.ToastId);
                    table.ForeignKey(
                        name: "FK_Toast_Beers_BeerId",
                        column: x => x.BeerId,
                        principalTable: "Beers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Toast_BeerId",
                table: "Toast",
                column: "BeerId");
        }
开发者ID:calielc,项目名称:EFCore,代码行数:29,代码来源:20160705041122_AddToast.cs


示例17: 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


示例18: Up

 public override void Up(MigrationBuilder migration)
 {
     migration.DropColumn(name: "Logo", table: "Teams");
     migration.AddColumn(
         name: "CheerleaderImage",
         table: "Teams",
         type: "nvarchar(max)",
         nullable: true);
     migration.AddColumn(
         name: "CoachImage",
         table: "Teams",
         type: "nvarchar(max)",
         nullable: true);
     migration.AddColumn(
         name: "DivisionId",
         table: "Teams",
         type: "int",
         nullable: true);
     migration.AddColumn(
         name: "HeaderImage",
         table: "Teams",
         type: "nvarchar(max)",
         nullable: true);
     migration.AddColumn(
         name: "LogoImage",
         table: "Teams",
         type: "nvarchar(max)",
         nullable: true);
     migration.AddForeignKey(
         name: "FK_Team_Division_DivisionId",
         table: "Teams",
         column: "DivisionId",
         referencedTable: "Divisions",
         referencedColumn: "DivisionId");
 }
开发者ID:knightofren,项目名称:lovelyjubblymvc6,代码行数:35,代码来源:20151027191524_editteam.cs


示例19: Down

 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_User_UserId", table: "AspNetUserClaims");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_User_UserId", table: "AspNetUserLogins");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_User_UserId", table: "AspNetUserRoles");
     migrationBuilder.DropForeignKey(name: "FK_Tag_TagColor_TagColorId", table: "Tag");
     migrationBuilder.DropForeignKey(name: "FK_Task_Tag_TagId", table: "Task");
     migrationBuilder.DropColumn(name: "Done", table: "Task");
     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>_User_UserId",
         table: "AspNetUserClaims",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_IdentityUserLogin<string>_User_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>_User_UserId",
         table: "AspNetUserRoles",
         column: "UserId",
         principalTable: "AspNetUsers",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_Tag_TagColor_TagColorId",
         table: "Tag",
         column: "TagColorId",
         principalTable: "TagColor",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
     migrationBuilder.AddForeignKey(
         name: "FK_Task_Tag_TagId",
         table: "Task",
         column: "TagId",
         principalTable: "Tag",
         principalColumn: "Id",
         onDelete: ReferentialAction.Restrict);
 }
开发者ID:Tarpsvo,项目名称:Travo-ASP.NET,代码行数:60,代码来源:20160116145942_Added+done+to+task..cs


示例20: Down

 protected override void Down(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.Sql(@"Alter view HierarchyPosts as
                             WITH    cte ( Id, ParentPostId, Depth, RootId )
                                             AS ( SELECT   Id,
                                                         ReplyToPostId,
                                                         0 as TheLevel,
                                                         Id as RootId
                                                 FROM     posts
                                                 where ReplyToPostId is null
                                                 And IsDeleted = 0
                                                 UNION ALL
                                                 SELECT   pn.Id,
                                                         pn.ReplyToPostId,
                                                         p1.Depth +1,
                                                         p1.RootId
                                                 FROM    Posts pn
                                                 INNER JOIN cte AS p1 on p1.Id = pn.ReplyToPostId
                                                 Where   pn.IsDeleted = 0
                                                 )
                             select cte.Id as PostId, ReplyToPostId, Depth, ForumId, LastChangedDate, PublishDate, Title, Body, IsModified, U.UserName, u.Id as UserId, RootId, IsDeleted, IsImportantReply
                             from  cte
                             INNER JOIN POSTS P ON CTE.ID = P.ID
                             INNER JOIN USERS u ON U.id = p.UserId");
 }
开发者ID:gdoron,项目名称:Forums,代码行数:25,代码来源:20160305225212_UserReviewsHierarchyView.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MigrationConventions类代码示例发布时间:2022-05-24
下一篇:
C# Migration类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap