-
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
Removing derived type does not update list of directly derived type in the base type #3894
Comments
@ESPNSTI could you provide a complete repro? A NRE in that piece of code indicates that there's a bug in a different place, but it would be hard to find without a repro. |
Sure, here is a test project that will reproduce it: |
Issue here is - while removing entity type, we do not remove it from the |
This also throws exception while removing derived type since when foreign keys are removed, relationship discovery convention will run and add new foreign key which disallows removing entity type. |
The entity type should be ignored before it is removed, so the convention shouldn't discover any relationship involving it. Perhaps there's an |
There are |
Yes, if the current type is ignored no conventions should run on it. We should also call HasBaseType(null) which will remove the type from _directlyderivedtypes before removing anything else. |
See #3555
I don't have a code sample yet, but I have some more information.
I reproduced this using EF7 RC1 final, .Net Framework 4.6 in VS2015.
The null reference happens in this section of Microsoft.Data.Entity.Metadata.Internal.InternalModelBuilder.Remove:
"Entity(directlyDerivedType.Name, ConfigurationSource.Convention)" ends up returning null because "IsIgnored(name, configurationSource)" in the "Entity" method is true.
In the case that I encountered, these are the variable values in this section:
entityType - System.Xml.Linq.XNode
directlyDerivedType.Name - System.Xml.Linq.XDocument
entityType.BaseType - null
configurationSource - DataAnnotation
It appears that while the code has changed, the problem still exists in the Dev branch (as of commit 2627626), in this case, "directlyDerivedType.Builder" returns null.
For a workaround, I ended up adding the following to my code.
I did not need this in Beta8.
It appears that the types listed above come from entity properties in my model that are ignored using this method:
The text was updated successfully, but these errors were encountered: