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

Make ColumnType return the mapped store type even when not set explicitly #8605

Closed
wants to merge 1 commit into from

Conversation

ajcvickers
Copy link
Member

Issue #8034, possible because of #7166

The idea here is to generate type mappings at model building type and then store them in the model. This allows property.RelationalAnnotationNames().ColumnType to always return the store type.

The solution is not perfect:

  • A convention runs when the model is built, which means that ColumnType will remain null during OnModelCreating. This could be changed by lots of conventions that run whenever something that could change the mapping is changed.
  • Because this is done by convention, and because conventions are not always run (e.g. ModelSnapshot, HistoryTable, using the ModelBuilder directly with an empty convention set) it means sometimes type mappings are not available. However, in the normal application scenario, they will always be available.

I will file an issue to look at these things post 2.0.

{
foreach (var property in modelBuilder.Metadata.GetEntityTypes().SelectMany(e => e.GetDeclaredProperties()))
{
new InternalPropertyBuilder(property, modelBuilder)
Copy link
Member

Choose a reason for hiding this comment

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

Is property.Builder unavailable here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@ajcvickers ajcvickers force-pushed the YoureJustMyType0525b branch 2 times, most recently from 51b813d to a694cfe Compare May 26, 2017 17:05
…itly

Issue #8034, possible because of #7166

The idea here is to generate type mappings at model building type and then store them in the model. This allows `property.RelationalAnnotationNames().ColumnType` to always return the store type.

The solution is not perfect:
- A convention runs when the model is built, which means that ColumnType will remain null during OnModelCreating. This could be changed by lots of conventions that run whenever something that could change the mapping is changed.
- Because this is done by convention, and because conventions are not always run (e.g. ModelSnapshot, HistoryTable, using the ModelBuilder directly with an empty convention set) it means sometimes type mappings are not available. However, in the normal application scenario, they will always be available.

I will file an issue to look at these things post 2.0.
@ajcvickers
Copy link
Member Author

Merged

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

Successfully merging this pull request may close these issues.

3 participants