The Entity Framework Core Fluent API configures how C# entities map to a database. Put model configuration in a DbContext subclass’s OnModelCreating method, where ModelBuilder exposes methods that can be chained to describe keys and relationships. section 4.3.3
EF Core also supports conventions and data annotations. Conventions infer mappings from naming patterns; annotations place settings on entity classes. Fluent API settings take precedence when they conflict with either approach. A practical split is to rely on conventions when possible, use annotations for entity-specific settings, and reserve Fluent API for modelwide configuration. section 4.3.3
Configure board-game relationships
For a board-game junction entity, Entity<BoardGames_Domains>().HasKey(...) selects the entity and gives its BoardGameId and DomainId a composite key. Relationship chains then start with HasOne and WithMany, identify the foreign key with HasForeignKey, mark it required with IsRequired, and set cascade deletion with OnDelete. The entity classes also need navigation properties for those relationships. section 4.3.3
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<BoardGames_Domains>()
.HasKey(i => new { i.BoardGameId, i.DomainId });
modelBuilder.Entity<BoardGames_Mechanics>()
.HasKey(i => new { i.BoardGameId, i.MechanicId });
}
The OnModelCreating listing shows two junction entities receiving composite keys through ModelBuilder method chains. section 4.3.3
To extend the model, configure a publisher-to-board-game one-to-many relationship or a category-to-board-game many-to-many relationship. In each case, add the relevant entities and navigation properties, then configure foreign keys and cascade rules in the DbContext. section 4.4.2 section 4.4.3



