-
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
Default DateTime value on smalldatetime column throws exception when saving new object #14457
Comments
Note for triage: smalldatetime range is "January 1, 1900, through June 6, 2079" |
This bug affects me too, so I'd be willing to work on this. Is it still possible get a fix for this bug integrated into 3.0? Browsing through the code of MigrationsSqlGenerator it looks like it is necessary to change signature of DefaultValue method:
This method for generating default value has no idea, what the type of the column is going to be. Because of this, it cannot get correct
and the implementation will prefer to use this type for resolving
Store/database type should be available at both calling sites (ColumnDefinition method) and in I understand this is breaking change, because other database providers depend on this method (such as SqlServer provider), but that should not be a problem, since 3.0 is already introducing some breaking changes, right? Any thoughts on this approach? |
@mirol-h That sounds like the right fix to me. Feel free to send a PR so we can further iterate on the implementation. |
OK, so I created PR including tests, but I would like to get some feedback, if they are OK (as I'm not familiar with tests for EF Core yet). After looking at existing tests for MigrationSqlGenerator, I added new test in
This issue also affects |
It is not possible to use DateTime default value for columns of type smalldatetime.
Steps to reproduce
Install nuget packages:
Add a migration:
Initial
Workarounds
Further technical details
EF Core version: 2.2.1
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
The text was updated successfully, but these errors were encountered: