EntityFramework uses datetime2 in queries, regardless of column type. RRS feed

  • Question

  • Hi,

    I have a problem when using Entity Framework.

    When I use a datetime, date, datetime2(0) column in the database and I set up my EDMX, the columns are mapped to DateTime. But when I put a select through EF to the table, the generated SQL always uses datetime2(7) parameters. Which is a severe problem, because the index on the table is not used caused by the conversion between datetime and datetime2.

    I read hints to set the ProvidertokenManifest to 2005, but this is not an option for me: We use date and time columns, which are not recognized by 2005.

    Is there a way to change the datatype used by EF within the select statement?


    Tuesday, November 29, 2011 1:00 PM


  • Hi pum,

    Why do set different types for DateTime? I afraid the mixed types won't be supported in EF now. Thanks for understanding. I think you can try to use Stored Procedure to return the types what you want.

    Have a nice day.

    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Alan_chen Friday, December 9, 2011 7:40 AM
    Friday, December 2, 2011 7:50 AM