-
Notifications
You must be signed in to change notification settings - Fork 3.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
Materialization uses incorrect column value with multiple derived types and shadow properties #6986
Comments
I am not able to repro this based on data provided above. SELECT TOP(1) [c].[ID], [c].[CreatedDate], [c].[Discriminator], [c].[Email], [c].[FirstName], [c].[IsPrimary], [c].[LastName], [c].[UserName], [c].[EmployerID], [c].[ServiceOperatorID], [c].[SystemProviderID], [c].[VehicleOperatorID]
FROM [Contacts] AS [c]
WHERE [c].[Discriminator] IN (N'VehicleOperatorContact', N'SystemProviderContact', N'ServiceOperatorContact', N'EmployerContact', N'Contact') |
I'll get that to you ASAP. The only nulls in the data are with the Ids that are specific to each child class of contact. I think that is where the bug lies. |
Data-corruption issue with shadow properties. It throws in this case due to presence of |
I've refactored my design to unblock myself for now by using a composition rather than inheritance approach to the different contact types. I've kept a tag and branch live of the original code state though, so if I can help with anything more don't hesitate to give me a shout. |
Is there any workaround for this issue? (without changing inheritance to composition) |
Clearing up milestone to discuss bringing this into 1.1.1. |
@xrkolovos - Another workaround would be to use non-shadow properties which does not encounter this issue. |
@smitpatel let us know if you don't think this is critical enough for 1.1.1 |
Having the same problem, and have not been able to find a suitable workaround (that does not involve removing inheritance). |
@nh43de - You can use non-shadow property which will not encounter this issue. |
I have tackled this issue in various ways but yet to arrive at fully working fix. But based on all the attempts so far, the fix for this issue would involve breaking changes & may be risky for patch release. |
@smitpatel to code the fix and then we will make the decision |
Justification: In the scenario where there are shadow properties in derived type, doing any query operation on the base type would give incorrect data for derived type. In certain cases where user model is more restricted like this it would throw exception. Risk: It is low risk. The fix changes the pipeline in case of the particularly faulty scenario and doesn't affect the path for any other cases. |
This patch bug is approved. Please use the normal code review process w/ a PR and make sure the fix is in the correct branch, then close the bug and mark it as done. |
Steps to reproduce
Load some data from your DbContext as follows...
Here's the definition for Contact, it's parent and it's children...
And my DbContext (editied)...
The issue
I am unable to load any data from my Contacts table in the database. Contacts is a base class with 4 inheriting types (all of which should be accessible). The only null fields in the database are the ID fields that are specific to each child class.
I CAN load data using the DbSet properties for each of the individual child classes with no problems whatsoever.
Here is the stack trace pulled from the Debug window by calling
Context.Contacts.First()
before allowing the line above to execute.
Further technical details
EF Core version: 1.1.0-preview1-final
Operating system: Windows 10
Visual Studio version: VS2015
Other details about my project setup: See above or on request
The text was updated successfully, but these errors were encountered: