Allow forcing DateTime parameters to DateTime or DateTime2#1147
Allow forcing DateTime parameters to DateTime or DateTime2#1147ajcvickers wants to merge 1 commit intorelease/6.3from
Conversation
|
Note: this is based on the workaround posted by @stasones on the issue that seems to have been successful for people. |
Fixes #578 Introduces an attribute which can be placed on a `DbContext`: ```C# [ForceDateTimeType(DbType.DateTime)] public class BloggingContext : DbContext { } ``` that will then cause all parameters used with this context type to be forced to the given DateTime type.
09c42aa to
4f1c41e
Compare
There was a problem hiding this comment.
I looked at this and talked to @ajcvickers:
-
The workaround that this PR adds to the product code (an interceptor that changes the parameter type) is already available to customers and simple enough.
-
As a fix, this also feels very limited because it cannot handle a mix of columns that are DateTime and DateTime2 in the same database.
Even if I am not sure we are going to implement a better fix, my recommendation is to move this as a workaround to the documentation and not take this change.
|
@divega Sounds good; I concur. |
|
Hi, I see this good fix. Does it mean our users could use it directly in our EF 6.3? |
|
Hi @ajcvickers , how are you? I tried to modify my demo but seems it doesn't work. Is there something I missed? Thank you for attention. |
|
@AlexChongMicrosoft Yes, you missed that we decided to not make this change. |
|
@ajcvickers Thanks a lot. So it makes sense that I couldn't apply this in my demo. Thank you for attention. |
Hello,I want to know how u to deal this problem? |
Hello,I want to know how u to deal this problem? |

Fixes #578
Introduces an attribute which can be placed on a
DbContext:that will then cause all parameters used with this context type to be forced to the given DateTime type.