After upgrading a working project from EF 4.0 to 4.1, I am now receiving the following error at run-time:
Map was called more than once for type ‘Everybody’ and at least one of the calls didn’t specify the target table name.
The code is:
public EverybodyConfiguration()
{
Map(e => e.Properties(p => new
{
p.EverybodyId,
p.FirstName,
p.LastName,
p.Initials,
p.CapsId,
p.DateModified
})).ToTable("Everybody");
Map(e => e.Properties(p => new
{
p.EverybodyId,
p.Status
})).ToTable("EverybodyStatus");
Map(e => e.Properties(p => new
{
p.EverybodyId,
p.Email,
p.BouncedFlag,
p.DoNotContactFlag
})).ToTable("EverybodyEmail");
}
The error message is confusing, because it indicates that the table name hasn’t been specified somewhere, but you can see in the code that it has.
The tables all have the same primary key column name.
Any suggestions?
The
ToTableyou call is the mapping for the whole entity (chained behindMap, method ofEntityTypeConfiguration). You must use theToTablemethod of theEntityMappingConfigurationwhich is the parameter of theActionpassed intoMap: