-
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
Moving RevEng provider code down into Relational.Design (where possible) #2741
Conversation
Fix issue 2713 - allow providers to only provide the relational model of the DB and have the inherited base class provide the enhanced model for code-generation. Also fix up some error messages.
} | ||
} | ||
|
||
public virtual EntityTypeCodeGeneratorHelper EntityTypeCodeGeneratorHelper(EntityTypeGeneratorModel model) |
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.
@ajcvickers It feels odd to me that the DbContextCodeGeneratorHelper method is abstract whereas the EntityTypeCodeGeneratorHelper method is virtual. That arises because DbContextCodeGeneratorHelper has the IRelationalMetadataExtensionProvider we discussed. I can make the EntityTypeCodeGeneratorHelper method abstract and simply override it SqlServerMetadataModelProvider to return new EntityTypeCodeGeneratorHelper() but that seems unnecessary?
if (((EntityType)otherEntityType) | ||
.FindAnnotation(ReverseEngineeringMetadataModelProvider.AnnotationNameEntityTypeError) == null) | ||
{ | ||
if (!foreignKey.IsUnique) |
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.
Why does this check matter?
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.
If the foreign key is unique you have a 1:1 (or 0..1:0..1 etc) relationship. NavPropInitializers are used to create a new empty HashSet for a NavigationProperty which represents a 1:N relationship.
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.
👍 Thanks for clarifying.
2 thoughts:
|
Yep - we should talk. |
(with the TODO's we discussed in person) |
Merged with 5c30958 |
Fix issue #2465 - making code generation templates non-provider specific.
Fix issue #2713 - allow providers to only provide the relational model of the DB and have the inherited base class provide the enhanced model for code-generation.
Also fix up some error messages.
Also updated to produce AddGeneratedNever() on a property which the KeyConvention would normally set up as AddGeneratedOnAdd() but where the underlying database column does not have identity set.