using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace EFCore.Jet.Integration.Test.Model08 { public class FileMap : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { // Primary Key builder.HasKey(t => t.Id); builder.Property(t => t.Id).ValueGeneratedOnAdd(); builder.ToTable("Files"); builder.Property(t => t.Id).HasColumnName("Id"); // Other Properties go here } } public class PageImageMap : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { // Table & Column Mappings builder.ToTable("PageImages"); // In EF Core this must be configured on the base type (see below for the error message) // Primary Key //builder.HasKey(t => t.Id); // builder.Property(t => t.Id).HasColumnName("Id"); // Other properties go here } } public class GalleryImageMap : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("GalleryImages"); // In EF core this must be configured on the base type (see below for the error message) // Primary Key //builder.HasKey(t => t.Id); // builder.Property(t => t.Id).HasColumnName("Id"); // Other properties go here } } } // Error message in case of wrong configuration /* * Initialization method EFCore.Jet.Integration.Test.Model08.Model08.Initialize threw exception.System.InvalidOperationException: * System.InvalidOperationException: A key cannot be configured on 'GalleryImage' because it is a derived type.The key must be * configured on the root type 'File'. If you did not intend for 'File' to be included in the model, ensure that it is not * included in a DbSet property on your context, referenced in a configuration call to ModelBuilder, or referenced from a * navigation property on a type that is included in the model.. */