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


C# MigrationBuilder.CreateIndex方法代码示例

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


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

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

示例2: Up

        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateIndex(
                name: "IX_UserQuestionData_QuestionId",
                table: "UserQuestionData",
                column: "QuestionId");

            migrationBuilder.CreateIndex(
                name: "IX_UserQuestionData_UserId",
                table: "UserQuestionData",
                column: "UserId");

            migrationBuilder.AddForeignKey(
                name: "FK_UserQuestionData_Questions_QuestionId",
                table: "UserQuestionData",
                column: "QuestionId",
                principalTable: "Questions",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_UserQuestionData_Users_UserId",
                table: "UserQuestionData",
                column: "UserId",
                principalTable: "Users",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
开发者ID:CSClassroom,项目名称:CSClassroom,代码行数:28,代码来源:20160923175252_Migration14.cs

示例3: Up

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

            migrationBuilder.DropForeignKey(
                name: "FK_RoleGroups_AspNetRoles_RoleId",
                table: "RoleGroups");

            migrationBuilder.DropIndex(
                name: "IX_RoleGroups_RoleId",
                table: "RoleGroups");

            migrationBuilder.DropIndex(
                name: "IX_AspNetRoles_RoleGroupId",
                table: "AspNetRoles");

            migrationBuilder.DropColumn(
                name: "RoleId",
                table: "RoleGroups");

            migrationBuilder.DropColumn(
                name: "RoleGroupId",
                table: "AspNetRoles");

            migrationBuilder.CreateTable(
                name: "RoleRoleGroups",
                columns: table => new
                {
                    RoleId = table.Column<int>(nullable: false),
                    RoleGroupId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoleRoleGroups", x => new { x.RoleId, x.RoleGroupId });
                    table.ForeignKey(
                        name: "FK_RoleRoleGroups_RoleGroups_RoleGroupId",
                        column: x => x.RoleGroupId,
                        principalTable: "RoleGroups",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_RoleRoleGroups_AspNetRoles_RoleId",
                        column: x => x.RoleId,
                        principalTable: "AspNetRoles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_RoleRoleGroups_RoleGroupId",
                table: "RoleRoleGroups",
                column: "RoleGroupId");

            migrationBuilder.CreateIndex(
                name: "IX_RoleRoleGroups_RoleId",
                table: "RoleRoleGroups",
                column: "RoleId");
        }
开发者ID:parys,项目名称:MyLiverpool,代码行数:60,代码来源:20160913140636_AddedRoleRoleGroupTable.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

        /// <summary>
        /// Creates initial tables for navigation management.
        /// </summary>
        /// <param name="builder">Instance of <see cref="MigrationBuilder"/></param>
        protected override void Up(MigrationBuilder builder)
        {
            builder.CreateTable(
                name: "Menus",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false, type: "uniqueidentifier"),
                    Name = table.Column<string>(nullable: false, type: "nvarchar(256)"),
                    NormalizedName = table.Column<string>(nullable: false, type: "nvarchar(256)"),
                    Title = table.Column<string>(nullable: true, type: "nvarchar(256)")
                },
                constraints: table => 
                {
                    table.PrimaryKey("PK_Menu", x => x.Id);   
                });

            builder.CreateTable(
                name: "MenuItems",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false, type: "uniqueidentifier"),
                    MenuId = table.Column<Guid>(nullable: false, type: "uniqueidentifier"),
                    ParentId = table.Column<Guid>(nullable: true, type: "uniqueidentifier"),
                    Title = table.Column<string>(nullable: true, type: "nvarchar(256)"),
                    CssClass = table.Column<string>(nullable: true, type: "nvarchar(256)"),
                    Url = table.Column<string>(nullable: true, type: "nvarchar(1024)")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MenuItem", x => x.Id);

                    table.ForeignKey(
                        name: "FK_MenuItem_Menu_MenuId",
                        column: x => x.MenuId,
                        principalTable: "Menus",
                        principalColumn: "Id",
                        //cascade delete all menu items if menu deleted
                        onDelete: ReferentialAction.Cascade);

                    table.ForeignKey(
                        name: "FK_MenuItem_MenuItem_ParentId",
                        column: x => x.ParentId,
                        principalTable: "MenuItems",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.NoAction);
                });

            builder.CreateIndex(
                name: "MenuNameIndex",
                table: "Menus",
                column: "NormalizedName");

            builder.CreateIndex(
                name: "MenuItemMenuIdIndex",
                table: "MenuItems",
                column: "MenuId");
        }
开发者ID:causer,项目名称:Itasu,代码行数:61,代码来源:InitialMigration.cs

示例6: Up

 protected override void Up(MigrationBuilder migrationBuilder)
 {
     migrationBuilder.CreateTable(
         name: "Content",
         columns: table => new
         {
             ContentGuid = table.Column<Guid>(nullable: false, defaultValueSql: "newsequentialid()"),
             InternalCaption = table.Column<string>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Content", x => x.ContentGuid);
         });
     migrationBuilder.CreateTable(
         name: "Translation",
         columns: table => new
         {
             Id = table.Column<int>(nullable: false)
                 .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
             ContentContentGuid = table.Column<Guid>(nullable: true),
             ContentId = table.Column<int>(nullable: false),
             ContentMarkup = table.Column<string>(nullable: false),
             Description = table.Column<string>(nullable: false),
             State = table.Column<int>(nullable: false),
             Title = table.Column<string>(nullable: false),
             UpdatedAt = table.Column<DateTime>(nullable: false),
             UrlName = table.Column<string>(nullable: false),
             Version = table.Column<int>(nullable: false)
         },
         constraints: table =>
         {
             table.PrimaryKey("PK_Translation", x => x.Id);
             table.ForeignKey(
                 name: "FK_Translation_Content_ContentContentGuid",
                 column: x => x.ContentContentGuid,
                 principalTable: "Content",
                 principalColumn: "ContentGuid");
         });
     migrationBuilder.CreateIndex(
         name: "IX_Translation_Version_ContentId",
         table: "Translation",
         columns: new[] { "Version", "ContentId" },
         unique: true);
     migrationBuilder.CreateIndex(
         name: "IX_Translation_Version_UrlName",
         table: "Translation",
         columns: new[] { "Version", "UrlName" },
         unique: true);
 }
开发者ID:nettsundere,项目名称:PersonalWebsite,代码行数:49,代码来源:20151107034644_CreateContentsAndTranslations.cs

示例7: Up

        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "TemperatureEntries",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreatedDateTime = table.Column<DateTime>(nullable: false),
                    DeviceId = table.Column<int>(nullable: false),
                    Humidity = table.Column<double>(nullable: false),
                    Presure = table.Column<double>(nullable: false),
                    TemperatureCelsius = table.Column<double>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TemperatureEntries", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TemperatureEntries_Devices_DeviceId",
                        column: x => x.DeviceId,
                        principalTable: "Devices",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_TemperatureEntries_DeviceId",
                table: "TemperatureEntries",
                column: "DeviceId");
        }
开发者ID:holtsoftware,项目名称:House,代码行数:29,代码来源:20160901151528_AddedTemperatureEntry.cs

示例8: Up

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

            migrationBuilder.DropIndex(
                name: "IX_Tweets_CategoryId",
                table: "Tweets");

            migrationBuilder.AlterColumn<int>(
                name: "CategoryId",
                table: "Tweets",
                nullable: false);

            migrationBuilder.CreateIndex(
                name: "IX_Tweets_CategoryId",
                table: "Tweets",
                column: "CategoryId");

            migrationBuilder.AddForeignKey(
                name: "FK_Tweets_Categories_CategoryId",
                table: "Tweets",
                column: "CategoryId",
                principalTable: "Categories",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
开发者ID:CCFS-Hou,项目名称:shouter,代码行数:28,代码来源:20160720153300_requiredCategory.cs

示例9: Up

        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "csids_PersistedGrants",
                columns: table => new
                {
                    Key = table.Column<string>(nullable: false),
                    Type = table.Column<string>(nullable: false),
                    ClientId = table.Column<string>(maxLength: 200, nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    Data = table.Column<string>(nullable: false),
                    Expiration = table.Column<DateTime>(nullable: false),
                    SiteId = table.Column<string>(maxLength: 36, nullable: false),
                    SubjectId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_csids_PersistedGrants", x => new { x.Key, x.Type });
                });

            migrationBuilder.CreateIndex(
                name: "IX_csids_PersistedGrants_SiteId",
                table: "csids_PersistedGrants",
                column: "SiteId");
        }
开发者ID:joeaudette,项目名称:cloudscribe,代码行数:25,代码来源:20161110153715_Initial.cs

示例10: Up

        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Categories",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Name = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Categories", x => x.Id);
                });

            migrationBuilder.AddColumn<int>(
                name: "CategoryId",
                table: "Tweets",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_Tweets_CategoryId",
                table: "Tweets",
                column: "CategoryId");

            migrationBuilder.AddForeignKey(
                name: "FK_Tweets_Categories_CategoryId",
                table: "Tweets",
                column: "CategoryId",
                principalTable: "Categories",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
开发者ID:CCFS-Hou,项目名称:shouter,代码行数:33,代码来源:20160720150556_categories.cs

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

示例12: Up

        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ProductsWithMaintenance",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false),
                    YearlyRate = table.Column<decimal>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductsWithMaintenance", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ProductsWithMaintenance_Products_Id",
                        column: x => x.Id,
                        principalTable: "Products",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_ProductsWithMaintenance_Id",
                table: "ProductsWithMaintenance",
                column: "Id",
                unique: true);
        }
开发者ID:MvcControlsToolkit,项目名称:MvcControlsToolkit.ControlsCore,代码行数:26,代码来源:20161006082819_business3.cs

示例13: Up

        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "CodeConstraints",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
                    CodeQuestionId = table.Column<int>(nullable: false),
                    ErrorMessage = table.Column<string>(nullable: false),
                    Frequency = table.Column<int>(nullable: false),
                    Order = table.Column<int>(nullable: false),
                    Regex = table.Column<string>(nullable: false),
                    Type = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CodeConstraints", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CodeConstraints_Questions_CodeQuestionId",
                        column: x => x.CodeQuestionId,
                        principalTable: "Questions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_CodeConstraints_CodeQuestionId",
                table: "CodeConstraints",
                column: "CodeQuestionId");
        }
开发者ID:CSClassroom,项目名称:CSClassroom,代码行数:31,代码来源:20160905210936_Migration4.cs

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

示例15: Up

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

            migrationBuilder.DropIndex(
                name: "IX_ProductsWithMaintenance_Id",
                table: "ProductsWithMaintenance");

            migrationBuilder.AddColumn<int>(
                name: "MaintenanceId",
                table: "Products",
                nullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "Id",
                table: "ProductsWithMaintenance",
                nullable: false)
                .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

            migrationBuilder.CreateIndex(
                name: "IX_Products_MaintenanceId",
                table: "Products",
                column: "MaintenanceId",
                unique: true);

            migrationBuilder.AddForeignKey(
                name: "FK_Products_ProductsWithMaintenance_MaintenanceId",
                table: "Products",
                column: "MaintenanceId",
                principalTable: "ProductsWithMaintenance",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
开发者ID:MvcControlsToolkit,项目名称:MvcControlsToolkit.ControlsCore,代码行数:35,代码来源:20161006101946_business4.cs


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