Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Created Issue: Code First: Empty entity configuration for abstract type can break mapping [842]

$
0
0
Consider the following:

var modelBuilder = new AdventureWorksModelBuilder();
modelBuilder.Entity<AbsInMiddle>().ToTable("Base");

// PROBLEM LINE BELOW
//modelBuilder.Entity<AbsInMiddleL1>();

modelBuilder.Entity<AbsInMiddleL2>()
.Map(
mc =>
{
mc.ToTable("L2");
mc.MapInheritedProperties();
});

var databaseMapping = BuildMapping(modelBuilder);

databaseMapping.Assert<AbsInMiddle>("Base").HasColumns("Id", "Data");

If the third line remains commented out then the test passes but if it is uncommented if will fail because mapping will incorrectly include an extra column in the "Base" table.

This is likely happening because the 3rd line will create an EntityTypeConfiguration for AbsInMiddleL1, which is causing something weird to happen in mapping configuration.

This is a bigger issue now that we have Lightweight Conventions because it becomes much easier to trigger creation of EntityTypeConfigurations for abstract entity types.


Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>