EFDesigner
EFDesigner copied to clipboard
Add association classes for EFCore5+
From https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-5.0/whatsnew
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder
.Entity<Post>()
.HasMany(p => p.Tags)
.WithMany(p => p.Posts)
.UsingEntity<PostTag>(
j => j
.HasOne(pt => pt.Tag)
.WithMany()
.HasForeignKey(pt => pt.TagId),
j => j
.HasOne(pt => pt.Post)
.WithMany()
.HasForeignKey(pt => pt.PostId),
j =>
{
j.Property(pt => pt.PublicationDate).HasDefaultValueSql("CURRENT_TIMESTAMP");
j.HasKey(t => new { t.PostId, t.TagId });
});
}
Visual representation should be a UML association class, similar to
Note that this kind of visual isn't currently supported by the Modeling SDK, so we'll have to come up with something clever.
Implemented in VS2022