EntityFramework.Docs icon indicating copy to clipboard operation
EntityFramework.Docs copied to clipboard

Show how to configure properties of derived types

Open tuespetre opened this issue 8 years ago • 5 comments

It would be a good idea to have examples showing the configuration of properties of derived types (like the RssUrl property having a max length or something.)


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

tuespetre avatar Aug 16 '18 13:08 tuespetre

There are some issues with consistency in this documentation. The initial Screenshot from SSMS shows a column of Discriminator with values of "Blog" and "RssBlog". The next chunk of code seems to name the column blog_type with values of "blog_base" and "blog_rss".

mdressel avatar Sep 03 '18 18:09 mdressel

@mdressel, that's the point. The screenshot shows the default Discriminator column name ("Discriminator") and the default values that would be included for each of the two types (the names of the types).

The next chunk of code is literally prefaced with a statement that you can change the default column and name values as you please, followed by the code example showing how to do so.

vanpyrzericj avatar Nov 29 '18 02:11 vanpyrzericj

@vanpyrzericj I understand, I just think it could be improved.

The documentation says "Below is an example showing a simple inheritance scenario and the data stored in a relational database table using the TPH pattern. The Discriminator column identifies which type of Blog is stored in each row." However, the example is not complete. It does not include the proper configuration to make the example work.

Instead it moves right into the next section which is, as you identified, intended to show changing the default column name values.

If the initial example was completed with the configuration that works with the example, it makes more sense.

Just my opinion.

mdressel avatar Nov 29 '18 02:11 mdressel

@mdressel gotcha. Out of curiosity, what other code would you want to see included? The snippet is enough to get the basic TPH pattern working. (Assuming, yes, that you've already done the basic setup of EF in the project).

vanpyrzericj avatar Nov 29 '18 03:11 vanpyrzericj

I followed the example and EF generated a duplicate ID column unexpectedly.

ntimmerman avatar Dec 20 '18 15:12 ntimmerman