Skip to content

Commit

Permalink
OnDeleteCascade behavior for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Jul 24, 2021
1 parent f16e2cf commit 894a178
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions LinkDotNet.Infrastructure/Persistence/Sql/BlogPostContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.Property(c => c.Id)
.ValueGeneratedOnAdd();

modelBuilder.Entity<BlogPost>()
.HasMany(t => t.Tags)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);

modelBuilder.Entity<Tag>()
.Property(c => c.Id)
.ValueGeneratedOnAdd();
Expand Down

0 comments on commit 894a178

Please sign in to comment.