实体框架连接到Oracle:ODP for .NET“不支持时间”; [英] Entity Framework connect to Oracle: ODP for .NET "does not support time"
问题描述
我建立了一个实体框架,在这里,我有一个通过连接字符串配置的远程Oracle Server,并且我没有运行某些单元测试来确认连接。我正在使用Oracle.ManagedDataAccess.Client
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
我遇到了错误:
System.NotSupportedException:Oracle Data Provider for .NET没有支持时间。
我找不到以前收到此错误的人。
我当时在想我的Oracle DB中的表可能会提到很多时间,但是它们只有DATE。
我必须这样做,否则我将无法以其他方式访问此项目的数据库。
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?
推荐答案
如果您将日期存储为'2015-06-30 08:13:24',是日期时间文字。
If you have dates stored as '2015-06-30 08:13:24' this is a date time literal.
作为文档状态
ODP.NET不支持与
相关的时间字面量和规范函数时间类型。
ODP.NET does not support Time literals and canonical functions related to the Time type.
在表中查找存储为VARCHAR2的日期。从经验上我可以说EF4至少没有DATE或TIMESTAMP字段的问题,所以您必须将问题放在其他地方。
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.
我通常不会考虑存储CHAR变量中的时间。在EF中,我经常不得不将CAST值转换为更可接受的数据类型。例如:
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;
在列名中使用Oracle关键字可能会遇到问题。
这是Oracle关键字的列表和保留字。 TIME已包含在列表中。如果您有称为TIME的列名,则可能是问题所在。
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.
尝试查看将TIME重命名为TIME_T或类似名称的表。
Try making a view of the table where you rename TIME to TIME_T or something.
这篇关于实体框架连接到Oracle:ODP for .NET“不支持时间”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!