-
Notifications
You must be signed in to change notification settings - Fork 53
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
[Bug] GenerateManyToMany produces wrong code when using AddHandlebarsTransformers #216
Comments
@tonysneed If I should provide a pull request with a failing unit test, I'd the three tables |
@Herdo Thanks for catching this. You can use the sample/ScaffoldingSample to repro the bug. Cheers. |
@tonysneed Provided the sample in the PR. One further thing I noticed while creating the sample: j.IndexerProperty<int>("EmployeeId").HasColumnName("EmployeeID");
j.IndexerProperty<int>("TerritoryId").HasColumnName("TerritoryID"); In the sample project, only one column was generated: j =>
{
j.HasKey("EmployeeId", "TerritoryId").HasName("PK_dbo.EmployeeTerritories");
j.ToTable("EmployeeTerritories");
j.IndexerProperty<string>("TerritoryId").HasMaxLength(20);
}); My guess is, that only columns that deviate from the standard are added as When the |
Is there a way to tell EF that a table is a many-to-many relationship, that has additional columns? Our many-to-many table has a created column that stores the date when it was created. But it causes EF to not scaffold it as a many-to-many, but rather one-to-many-to-one. |
Might be unrelated, but since the Many to Many properties in the scaffolding are nav properties, shouldn't these be using the navPropertyTransformer rather than the entity names? Line 817 in 2b65b77
|
Describe the bug
HbsCSharpDbContextGenerator.GenerateManyToMany
does not respect configured design time service transformations (Microsoft.EntityFrameworkCore.Design.IDesignTimeServices.ConfigureDesignTimeServices). WhenAddHandlebarsScaffolding
is configured withpropertyTransformer
, wrongIndexProperty<T>
values are configured, basically ignoringAddHandlebarsScaffolding
.As example, the generated index property may look like this:
j.IndexerProperty<int>("UserId").HasColumnName("UserId");
This wrong (or rather missing) transformation is causing a runtime issue:
Expected behavior
The configured
EntityPropertyInfo
of thepropertyTransformer
inAddHandlebarsTransformers
would also transform the type of the generatedIndexProperty<T>
.For example, for properties matching the name
UserId
map to the typeMyNamespace.InternalUserId
, the index property should be generated asIndexProperty<MyNamespace.InternalUserId>
.To Reproduce
IDesignTimeServices
:User
with columnUserId
as primary keySubscription
with columnSubscriptionId
as primary keyUserSubscription
with columnsUserId
andSubscriptionId
as combined primary keyUserSubscription
Make My Life Easier
I'll add this:
If possible, create a pull request that contains a failing unit test.
Otherwise, use the
sample/ScaffoldingSample
project to reproduce the bug.The text was updated successfully, but these errors were encountered: