Entityframework.docs: Show how to configure properties of derived types

Created on 16 Aug 2018  Â·  5Comments  Â·  Source: dotnet/EntityFramework.Docs

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.

area-entity-mapping

Most helpful comment

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".

All 5 comments

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, 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 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 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).

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jpeckham picture jpeckham  Â·  3Comments

CeciAc picture CeciAc  Â·  4Comments

norvegec picture norvegec  Â·  3Comments

CubeSpark picture CubeSpark  Â·  3Comments

ajcvickers picture ajcvickers  Â·  4Comments