SeanMC
SeanMC

Reputation: 2346

Entity Framework connect to Oracle: ODP for .NET "does not support time"

I have an Entity framework set up where I have a remote Oracle Server that I've configured through the connection string and I'm not running some unit Tests to confirm connection. I'm using Oracle.ManagedDataAccess.Client

I'm getting the error: System.NotSupportedException: Oracle Data Provider for .NET does not support Time.

I can't find anyone getting this error before. I was thinking my tables in my Oracle DB might have many mentions to time, but they only have DATE. I have to do it this way, I won't be able to just access the DB a different way for this project.

What could be causing this error? How can I remedy it?

Upvotes: 3

Views: 1208

Answers (1)

kevinskio
kevinskio

Reputation: 4551

If you have dates stored as '2015-06-30 08:13:24' this is a date time literal.

As the documentation states

ODP.NET does not support Time literals and canonical functions related to the Time type.

Look through your tables for dates stored as VARCHAR2. I can say from experience that EF4 at a minimum has no problem with DATE or TIMESTAMP fields so the problem you have has to be somewhere else.

I would not normally consider storing a time in a CHAR variable. In EF I have frequently had to CAST values to a more acceptable datatype. As an example:

select CAST(your_date ||' '||your_time AS DATE) AS your_field from your_table;

You may be running into an issue with using Oracle keywords in your column names. Here is a list of Oracle keywords and reserved words. TIME is included in the list. If you have column names called TIME this could be your problem.

Try making a view of the table where you rename TIME to TIME_T or something.

Upvotes: 4

Related Questions