-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document TPC #4080
Document TPC #4080
Conversation
c4e107a
to
be61644
Compare
|
||
In the TPT mapping pattern, all the types are mapped to individual tables. Properties that belong solely to a base type or derived type are stored in a table that maps to that type. Tables that map to derived types also store a foreign key that joins the derived table with the base table. | ||
|
||
[!code-csharp[Main](../../../samples/core/Modeling/Inheritance/FluentAPI/TPTConfiguration.cs?name=TPTConfiguration)] | ||
|
||
> [!TIP] | ||
> Instead of calling `ToTable` on each entity type you can call `modelBuilder.Entity<Blog>().UseTptMappingStrategy()` on each root entity type and the table names will be generated by EF. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we modify the sample to use UseTptMappingStrategy by default, and show ToTable only for when you want to customize the table names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we say that TPT should only be used with existing databases I think that the ToTable
way will be more common.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We say it should, but that doesn't necessarily means that's how users use it :) I'd still say that UseTptMappingStrategy should be the default as long it works (i.e. your tables do align with the default naming), and that ToTable should only be used when that's not the case.
But am OK if you prefer to keep as-is.
[!code-csharp[Main](../../../samples/core/Modeling/Inheritance/FluentAPI/TPCConfiguration.cs?name=TPCConfiguration)] | ||
|
||
> [!TIP] | ||
> Instead of calling `ToTable` on each entity type just calling `modelBuilder.Entity<Blog>().UseTpcMappingStrategy()` on each root entity type will generate the table names by convention. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above for TPT - I think we expect most users to use the new UseTp*MappingStrategy, rather than ToTable, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UseTpcMappingStrategy
needs to be called anyway, I don't think that removing the ToTable
calls from the sample improves it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it's redundant code for many uses cases - we don't have ToTable in regular, non-inheritance code samples. But anyway...
10897d0
to
83dd930
Compare
83dd930
to
0c6548c
Compare
Fixes #3764
Fixes #3765