Fixed error in Product : CustomDescription relationsship.

On Delete behaviour changed from 'Restrict' to 'SetNull' to allow direct deletion of a CD without modifying/unlinking related products first.
pull/1/head
Basimodo 2021-07-08 11:38:34 +07:00
parent 3fba124380
commit c40525009c
1 changed files with 1 additions and 1 deletions

@ -158,7 +158,7 @@ namespace Gremlin.GremlinData.DBClasses
public void Configure(EntityTypeBuilder<Product> entity)
{
entity.HasKey(e => e.ProductId);
entity.HasOne(d => d.CustomDescription).WithMany(p => p.Products).HasForeignKey("CustomDescriptionId").IsRequired(false).OnDelete(DeleteBehavior.Restrict); //.IsRequired() is just fyi, because it is overwritten by FK property nullability (nullable = optional relationship, non-nullable = required relationship)!
entity.HasOne(d => d.CustomDescription).WithMany(p => p.Products).HasForeignKey("CustomDescriptionId").IsRequired(false).OnDelete(DeleteBehavior.SetNull); //.IsRequired() is just fyi, because it is overwritten by FK property nullability (nullable = optional relationship, non-nullable = required relationship)!
entity.HasOne(p => p.ProductLine).WithMany(d => d.Products).HasForeignKey("ProductLineCode").IsRequired(true).OnDelete(DeleteBehavior.Restrict);
entity.Property(e => e.CustomDescriptionId).IsRequired(false);