Open nick5454 opened 3 years ago
It looks like the hardest part is detect if the table has a "table base class" and if so then add the HasDiscriminator column
I've thought about seeing if the generator can accurately determine base class columns (quite difficult) and discriminator columns (easier).
Currently the generator does not use the .HasDiscriminator()
and outputs the tables are they are in the database. So everything will work fine, but probably not exactly how you wanted it. It's something I would like to get added and working in the future. It will have to be a Settings.UseDiscriminators
boolean setting so as not to break existing code when it eventually gets implemented.
@sjh37 I would think maybe adding a DiscrimatorAttribute to your package and we can decorate discrimators that way. If the table is marked as one then we can inject the discriminator code.
Thoughts?
That would be the other way to do it. Let the user decide which tables & columns to use .HasDiscriminator()
for.
We moved the EF from CodeFirstDatabase to your POCO Generator.
One issue we have left is how EF creates the "HasDescriminator" when the code has say this
Table: Address Columns: AddressId, Addr1, Addr2, City, State, Zip, Descriminator
Classes: BusinessAddress : Address HomeAddress : Address
How Ef has defined inside the Designer
Is the discriminator only used EF and I can remove it or is there a way to get the Generator to build Discriminator columns based on extended table classes like the example above?