Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

lajones
Copy link
Contributor

@lajones lajones commented Jul 29, 2015

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.

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)
Copy link
Contributor Author

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks for clarifying.

@natemcmaster
Copy link
Contributor

2 thoughts:

  • Testing. Is it also possible to abstract some of the testing? (Don't need to do in this PR).
  • Abstraction. Just by inspection, I speculate we will need to make some changes to our abstraction choices as we build SQLite and other relational providers. (No action item: just discussion).

@lajones
Copy link
Contributor Author

lajones commented Jul 31, 2015

Yep - we should talk.
Re testing - I have a separate testing issue - let's talk about the abstraction before I carry on with that.
Re abstraction here - a SQLite provider should only have to provide an override of ConstructRelationalModel(). If you find you're doing more than that then we should definitely talk.

@natemcmaster
Copy link
Contributor

:shipit: (with the TODO's we discussed in person)

@natemcmaster
Copy link
Contributor

Merged with 5c30958

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants