本文整理汇总了C#中MigrationBuilder.AddUniqueConstraint方法的典型用法代码示例。如果您正苦于以下问题:C# MigrationBuilder.AddUniqueConstraint方法的具体用法?C# MigrationBuilder.AddUniqueConstraint怎么用?C# MigrationBuilder.AddUniqueConstraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MigrationBuilder
的用法示例。
在下文中一共展示了MigrationBuilder.AddUniqueConstraint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_ReleaseBatchItem_ReleaseBatch_ReleaseBatchId", schema: "kraken", table: "ReleaseBatchItem");
migrationBuilder.AddUniqueConstraint(
name: "AK_ReleaseBatch_Name",
schema: "kraken",
table: "ReleaseBatch",
column: "Name");
migrationBuilder.AddForeignKey(
name: "FK_ReleaseBatchItem_ReleaseBatch_ReleaseBatchId",
schema: "kraken",
table: "ReleaseBatchItem",
column: "ReleaseBatchId",
principalSchema: "kraken",
principalTable: "ReleaseBatch",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例2: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "UniqueId",
table: "Users",
nullable: false);
migrationBuilder.AddUniqueConstraint(
name: "AK_Users_UniqueId",
table: "Users",
column: "UniqueId");
migrationBuilder.AddUniqueConstraint(
name: "AK_SectionMemberships_ClassroomMembershipId_SectionId",
table: "SectionMemberships",
columns: new[] { "ClassroomMembershipId", "SectionId" });
migrationBuilder.AddUniqueConstraint(
name: "AK_ClassroomMemberships_UserId_ClassroomId",
table: "ClassroomMemberships",
columns: new[] { "UserId", "ClassroomId" });
migrationBuilder.AddUniqueConstraint(
name: "AK_QuestionCategories_ClassroomId_Name",
table: "QuestionCategories",
columns: new[] { "ClassroomId", "Name" });
migrationBuilder.AddUniqueConstraint(
name: "AK_Questions_QuestionCategoryId_Name",
table: "Questions",
columns: new[] { "QuestionCategoryId", "Name" });
migrationBuilder.AddUniqueConstraint(
name: "AK_Sections_ClassroomId_Name",
table: "Sections",
columns: new[] { "ClassroomId", "Name" });
migrationBuilder.AddUniqueConstraint(
name: "AK_Classrooms_Name",
table: "Classrooms",
column: "Name");
}
示例3: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_Gebruiker_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_Gebruiker_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_Gebruiker_UserId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_BestellingMateriaalItem_Bestelling_BestellingId", table: "BestellingMateriaalItem");
migrationBuilder.DropForeignKey(name: "FK_BestellingMateriaalItem_MateriaalItem_MateriaalItemId", table: "BestellingMateriaalItem");
migrationBuilder.DropForeignKey(name: "FK_MateriaalDoelgroep_Doelgroep_DoelgroepId", table: "MateriaalDoelgroep");
migrationBuilder.DropForeignKey(name: "FK_MateriaalDoelgroep_Materiaal_MateriaalId", table: "MateriaalDoelgroep");
migrationBuilder.DropForeignKey(name: "FK_MateriaalItem_Materiaal_MateriaalId", table: "MateriaalItem");
migrationBuilder.DropForeignKey(name: "FK_MateriaalLeergebied_Leergebied_LeergebiedId", table: "MateriaalLeergebied");
migrationBuilder.DropForeignKey(name: "FK_MateriaalLeergebied_Materiaal_MateriaalId", table: "MateriaalLeergebied");
migrationBuilder.DropForeignKey(name: "FK_MateriaalVerlanglijst_Materiaal_MateriaalId", table: "MateriaalVerlanglijst");
migrationBuilder.DropForeignKey(name: "FK_MateriaalVerlanglijst_Verlanglijst_VerlanglijstId", table: "MateriaalVerlanglijst");
migrationBuilder.DropForeignKey(name: "FK_Uitleeninformatie_MateriaalItem_MateriaalItemId", table: "Uitleeninformatie");
migrationBuilder.DropForeignKey(name: "FK_Verlanglijst_Gebruiker_GebruikerId1", table: "Verlanglijst");
migrationBuilder.DropColumn(name: "GebruikerId", table: "Verlanglijst");
migrationBuilder.DropColumn(name: "GebruikerId1", table: "Verlanglijst");
migrationBuilder.AddColumn<int>(
name: "GebruikerForeignKey",
table: "Verlanglijst",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "GebruikerForeignKey",
table: "AspNetUsers",
nullable: false,
defaultValue: 0);
migrationBuilder.AddUniqueConstraint(
name: "AK_Gebruiker_GebruikerForeignKey",
table: "AspNetUsers",
column: "GebruikerForeignKey");
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>_Gebruiker_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_Gebruiker_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>_Gebruiker_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_BestellingMateriaalItem_Bestelling_BestellingId",
table: "BestellingMateriaalItem",
column: "BestellingId",
principalTable: "Bestelling",
principalColumn: "BestellingId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_BestellingMateriaalItem_MateriaalItem_MateriaalItemId",
table: "BestellingMateriaalItem",
column: "MateriaalItemId",
principalTable: "MateriaalItem",
principalColumn: "MateriaalItemId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_MateriaalDoelgroep_Doelgroep_DoelgroepId",
table: "MateriaalDoelgroep",
column: "DoelgroepId",
principalTable: "Doelgroep",
principalColumn: "DoelgroepId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_MateriaalDoelgroep_Materiaal_MateriaalId",
table: "MateriaalDoelgroep",
column: "MateriaalId",
principalTable: "Materiaal",
principalColumn: "MateriaalId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_MateriaalItem_Materiaal_MateriaalId",
table: "MateriaalItem",
//.........这里部分代码省略.........
示例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.DropForeignKey(name: "FK_Contact_Item_Contact_contactId", table: "Contact_Item");
migrationBuilder.DropForeignKey(name: "FK_Ferias_Funcionario_funcionarioId", table: "Ferias");
migrationBuilder.DropForeignKey(name: "FK_Ferias_Itens_Funcionario_funcionarioId", table: "Ferias_Itens");
migrationBuilder.DropForeignKey(name: "FK_FuncFerias_Funcionario_funcionarioId", table: "FuncFerias");
migrationBuilder.DropForeignKey(name: "FK_FuncInfFerias_Funcionario_funcionarioId", table: "FuncInfFerias");
migrationBuilder.DropForeignKey(name: "FK_Funcionario_Departamento_departamentoId", table: "Funcionario");
migrationBuilder.DropForeignKey(name: "FK_Historio_Ferias_Item_Ferias_Itens_ferias_item_id", table: "Historio_Ferias_Item");
migrationBuilder.AlterColumn<string>(
name: "contactId",
table: "Contact_Item",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "contactId",
table: "Contact",
nullable: false,
defaultValue: "");
migrationBuilder.AddUniqueConstraint(
name: "AK_Contact_contactId",
table: "Contact",
column: "contactId");
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.AddForeignKey(
name: "FK_Contact_Item_Contact_contactId",
table: "Contact_Item",
column: "contactId",
principalTable: "Contact",
principalColumn: "contactId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Ferias_Funcionario_funcionarioId",
table: "Ferias",
column: "funcionarioId",
principalTable: "Funcionario",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Ferias_Itens_Funcionario_funcionarioId",
table: "Ferias_Itens",
column: "funcionarioId",
principalTable: "Funcionario",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_FuncFerias_Funcionario_funcionarioId",
table: "FuncFerias",
column: "funcionarioId",
principalTable: "Funcionario",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_FuncInfFerias_Funcionario_funcionarioId",
table: "FuncInfFerias",
column: "funcionarioId",
principalTable: "Funcionario",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Funcionario_Departamento_departamentoId",
table: "Funcionario",
//.........这里部分代码省略.........
示例5: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_SectionMemberships_Sections_SectionId",
table: "SectionMemberships");
migrationBuilder.DropIndex(
name: "IX_Users_UniqueId",
table: "Users");
migrationBuilder.DropIndex(
name: "IX_SectionMemberships_SectionId",
table: "SectionMemberships");
migrationBuilder.DropIndex(
name: "IX_SectionMemberships_ClassroomMembershipId_SectionId",
table: "SectionMemberships");
migrationBuilder.DropIndex(
name: "IX_ClassroomMemberships_UserId_ClassroomId",
table: "ClassroomMemberships");
migrationBuilder.DropIndex(
name: "IX_QuestionCategories_ClassroomId_Name",
table: "QuestionCategories");
migrationBuilder.DropIndex(
name: "IX_Questions_QuestionCategoryId_Name",
table: "Questions");
migrationBuilder.DropIndex(
name: "IX_Sections_ClassroomId_Name",
table: "Sections");
migrationBuilder.DropIndex(
name: "IX_Classrooms_Name",
table: "Classrooms");
migrationBuilder.DropColumn(
name: "IsPrivate",
table: "QuestionCategories");
migrationBuilder.DropColumn(
name: "AllowPartialCredit",
table: "Questions");
migrationBuilder.DropColumn(
name: "IsPrivate",
table: "Questions");
migrationBuilder.DropColumn(
name: "DateModified",
table: "Questions");
migrationBuilder.DropColumn(
name: "FullGeneratorFileContents",
table: "Questions");
migrationBuilder.DropColumn(
name: "FullGeneratorFileLineOffset",
table: "Questions");
migrationBuilder.DropTable(
name: "UserQuestionSubmission");
migrationBuilder.DropTable(
name: "UserQuestionData");
migrationBuilder.AddColumn<bool>(
name: "RandomizeAnswers",
table: "Questions",
nullable: true);
migrationBuilder.AlterColumn<string>(
name: "UniqueId",
table: "Users",
nullable: false);
migrationBuilder.AddUniqueConstraint(
name: "AK_Users_UniqueId",
table: "Users",
column: "UniqueId");
migrationBuilder.AddUniqueConstraint(
name: "AK_SectionMemberships_ClassroomMembershipId_SectionId",
table: "SectionMemberships",
columns: new[] { "ClassroomMembershipId", "SectionId" });
migrationBuilder.AddUniqueConstraint(
name: "AK_ClassroomMemberships_UserId_ClassroomId",
table: "ClassroomMemberships",
columns: new[] { "UserId", "ClassroomId" });
migrationBuilder.AddUniqueConstraint(
name: "AK_QuestionCategories_ClassroomId_Name",
table: "QuestionCategories",
columns: new[] { "ClassroomId", "Name" });
migrationBuilder.AddUniqueConstraint(
name: "AK_Questions_QuestionCategoryId_Name",
//.........这里部分代码省略.........