public class Post { public string Id { get; private set; } public string Content { get; set; } public string UserId { get; set; } public DateTime Created { get; set; } public DateTime Edited { get; set; } public List<Image> Images; } public class Draft { public string IdentityGuid { get; private set; } public string Id { get; set; } public string Content { get; set; } public string UserId { get; set; } public string Title { get; set; } public DateTime Created { get; set; } public DateTime Edited { get; set; } public List<Image> Images; } public class Image { public string UserId { get; set; } public string Name { get; set; } public string Type { get; set; } public int TypeId { get; set; } public string Description { get; set; } public string Content_Type { get; set; } public string Filename { get; set; } public string Url { get; set; } public long Size { get; set; } public DateTime Created { get; set; } public DateTime Edited { get; set; } }
public void Configure(EntityTypeBuilder<Draft> draftConfiguration) { draftConfiguration.HasMany(b => b.Images) .WithOne() .HasForeignKey("TypeId") .OnDelete(DeleteBehavior.Cascade); } public void Configure(EntityTypeBuilder<Post> postConfiguration) { draftConfiguration.HasMany(b => b.Images) .WithOne() .HasForeignKey("TypeId") .OnDelete(DeleteBehavior.Cascade); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)