cancel
Showing results for 
Search instead for 
Did you mean: 

Entity Framework Expecting Time column to be DateTime but actually TimeSpan

2,817

Using Entity Framework and VS2010 to access Sybase SQL 12 database. I have a DATE (qdate) and a TIME (qtime) column in the table. Both fields are part of the table's primary key. When I attempt to retrieve any record from the table, I get the error message "The type of the key field 'qtime' is expected to be System.DateTime, but the value provided is actually of type System.TimeSpan. Has anyone else run into this and if so, how did you remedy the situation?

Accepted Solutions (0)

Answers (1)

Answers (1)

Here's what I eventually did to get around this. 1) since the complaint seemed to deal with using a TIME field in the Primary Key, 2) I added an autoincrement SEQNO field (bigint) and made that the Primary Key (probably a better design) and that seems to get around the issue. Fortunately I had the latitude to be able to do that, but...in the future I'll avoid using TIME columns in keys or indexes unless absolutely necessary. PB doesn't seem to have an issue with it, but Entity-Framework appears to choke on it.