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 sure migration model has type mapping #20652

Merged
merged 1 commit into from
Apr 15, 2020
Merged

Make sure migration model has type mapping #20652

merged 1 commit into from
Apr 15, 2020

Conversation

AndriySvyryd
Copy link
Member

Fixes #20517


private IModel FinalizeModel(IModel model)
{
if (model is IConventionModel conventionModel)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a Check() instead? When is it not an IConventionModel?

Copy link
Member Author

@AndriySvyryd AndriySvyryd Apr 15, 2020

Choose a reason for hiding this comment

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

Migration exposes it as IModel, so enforcing that it has to be an IConventionModel goes against Liskov's principle. Even though in all practical scenarios in would be one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Check.DebugAssert() then? My point is that if the model is not an IConventionModel and you expect this code to do something, it will fail to do so silently, and that could be hard to track down later.

If there are valid scenarios where this would not be an IConventionModel and this code should do nothing, then you can ignore this comment. I just wasn't sure what those would be.

Copy link
Member Author

Choose a reason for hiding this comment

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

If it's not an IConventionModel we can't do anything to it, so we'll just assume that it already has the expected annotations, if it doesn't it will be obvious from the exception messages thrown after this.

Copy link
Contributor

@bricelam bricelam left a comment

Choose a reason for hiding this comment

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

:shipit:

@AndriySvyryd
Copy link
Member Author

Better late than never 😆

@bricelam
Copy link
Contributor

lol, yep. Slowly catching up...

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.

Entity Framework Core - Code-First throws exception
3 participants