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

HasDefaultValue type casting #6056

Closed
dazinator opened this issue Jul 12, 2016 · 1 comment
Closed

HasDefaultValue type casting #6056

dazinator opened this issue Jul 12, 2016 · 1 comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@dazinator
Copy link

dazinator commented Jul 12, 2016

Steps to reproduce

Add a property to your entity that is a short, specify an integer as a default value:

entity.Property(e => e.SomeShortProperty).HasDefaultValue(3);

The issue

This worked in RC1, but in RTM:

image

It looks like in RTM, EF7 doesn't try to type cast, so it sees an int as an invalid value for a short.

Changing the code to this works:

entity.Property(e => e.SomeShortProperty).HasDefaultValue((short)3);

I think it would be better if the type can be safely cast, then to handle that automatically.

Further technical details

EF Core version: (RTM)
Operating system: Windows 8
Visual Studio version: 2015

@dazinator dazinator changed the title HasDefaultValue HasDefaultValue type casting Jul 12, 2016
@rowanmiller rowanmiller added this to the 1.1.0 milestone Jul 15, 2016
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jul 22, 2016
@dazinator
Copy link
Author

👍 thanks :-)

@ajcvickers ajcvickers modified the milestones: 1.1.0-preview1, 1.1.0 Oct 15, 2022
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

3 participants