Skip to content

Commit

Permalink
Modify Migration of RoleParentChild Table
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamed-Bagherpour committed Nov 4, 2023
1 parent 22a478b commit 53e6a3f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
model.HasOne(u => u.Parent)
.WithMany(u => u.Parents)
.HasForeignKey(u => u.ParentId);
.HasForeignKey(u => u.ParentId)
.OnDelete(DeleteBehavior.Restrict);
model.HasOne(u => u.Child)
.WithMany(u => u.Children)
.HasForeignKey(u => u.ChildId);
.HasForeignKey(u => u.ChildId)
.OnDelete(DeleteBehavior.Restrict);
});

var result = base.AutoModelCreating(modelBuilder);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ protected override void Up(MigrationBuilder migrationBuilder)
column: x => x.ChildId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_RoleParentChildren_Roles_ParentId",
column: x => x.ParentId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Restrict);
});

migrationBuilder.InsertData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,13 +649,13 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasOne("EasyMicroservices.AuthenticationsMicroservice.Database.Entities.RoleEntity", "Child")
.WithMany("Children")
.HasForeignKey("ChildId")
.OnDelete(DeleteBehavior.Cascade)
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("EasyMicroservices.AuthenticationsMicroservice.Database.Entities.RoleEntity", "Parent")
.WithMany("Parents")
.HasForeignKey("ParentId")
.OnDelete(DeleteBehavior.Cascade)
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Child");
Expand Down

0 comments on commit 53e6a3f

Please sign in to comment.