Is there a way (ef-core-5.0) to force the creation of an intermediate table Blog_Post
for the following code?
Blog <= 0,n => Blog_Post <= 1,1 => Post
the code is the following
class MyContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
}
public class Blog
{
public int Id { get; set; }
public string Url { get; set; }
}
public class Post
{
public int Id { get; set; }
public string Title { get; set; }
public string Content { get; set; }
}
From one side, I want to separate concerns, and not add too much DB stuff on the business classes. So I would prefer do not use as much as possible an explicit DB configuration, attributes, ad-hoc table classes etc, or probably better a Fluent configuration...
From another, there's no many to many relation between Blog and Post.
However, such link tables are necessary to be built for a specific reason in the DB.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…