I'm attempting to use Table Per Hierarchy for the first time, and the
following scenario is supposed to work in EF6 but doesn't seem appear to
work with DevForce when generating the ibmmx.
Example:
BaseEntity
Id
Name
Entity1
ForeignKeyId
Entity2
ForeignKeyId
Entity3
SomeOtherProperty
The default behavior is it will create ForeignKeyId and ForeignKeyId1
so the solution is to add the [Column] attribute to each to define it as ForeignKeyId to use the fluent api like:
modelBuilder.Entity<Entity1>().Property(p => p.ForeignKeyId).HasColumnName("ForeignKeyId"); modelBuilder.Entity<Entity2>().Property(p => p.ForeignKeyId).HasColumnName("ForeignKeyId");
|
When you do so, you get the following error:
Error
7 An error occurred during metadata generation and a metadata file
could not be created. Error: One or more validation errors were
detected during model generation:
ForeignKeyId: : There is no property with name 'ForeignKeyId' defined in the type referred to by Role 'BaseEntity'.
I
really would like them to both map to ForeignKeyId otherwise it is
going to clutter up the table, and I might as well switch to a TPT
scenario in that case.
I hope I've explained that correctly. Let me know if you need any more information.
Thanks,
Mark