oracle - EF + ODP.NET : The specified value is not an instance of type 'Edm.Decimal'

标签 oracle entity-framework entity-framework-4 odp.net odp.net-managed

我正在使用 Oracle 的托管 ODP.NET 客户端 Entity Framework .它工作正常。但是我在不同的服务器上有不同的行为。我很确定它与 DLL 版本有关,但到目前为止我找不到任何差异。

我有这些表:

create table parent (
   parent_id number primary_key, 
   data varchar2(100)
);
create table child (
   child_id number primary key, 
   parent_id number references parent(parent_id)
);

而这些实体:
public class Parent {
    Int32 Id { get; set; }
    string Data { get; set; }
}
public class Child {
    Int32 Id { get; set; }
    Parent Parent { get; set; }
}

这是代码:
Entities e = new Entities(connectionString);
Parent p = new Parent();
parent.Data = "TEST DATA!";
Child c = new Child();
c.Parent = p;
e.Children.AddObject(c);
e.SaveChanges(); // exception here, in one server, not on the other

我有一个 触发器 自动填充 id在( parent 和 child )上,我正在使用 Store Generated Pattern = Identity关于 Entity Framework 配置。

我的问题是:

在我的开发机器上,它按预期完美运行。两行都插入到各自的表中。但是,在服务器上,我收到一条错误消息:The specified value is not an instance of type 'Edm.Decimal' .

更多信息:

Oracle.ManagedDataAccess (v 4.121.1.0)
Entity Framework (v4.0.30319.1)

在两者上:开发机器(工作)+服务器(不工作)。

想法?

最佳答案

尝试更改您的 Id 的定义来自 Int32 的专栏至 Decimal .我已经多次遇到这个问题,我认为已经解决了。

public class Parent {
    Decimal Id { get; set; }
    string Data { get; set; }
}
public class Child {
    Decimal Id { get; set; }
    Parent Parent { get; set; }
}

关于oracle - EF + ODP.NET : The specified value is not an instance of type 'Edm.Decimal' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19691843/

相关文章:

sql - 为什么我的层次结构查询显示重复记录?

java - ORA-01847 日期必须介于 1 和月份的最后一天之间 - 将日期插入 Oracle 数据库

sql - Like 从句的模式匹配

c# - 如何从mvc项目中的引用表创建下拉列表

oracle - 运行pl/sql的目标列表中不存在程序?

c# - IComparer 逻辑将层次结构排序为平面列表

c# - 数据库首次迁移 EF Core

entity-framework-4 - 为什么 Model First Entity Framework 4.0 模型在创建之前需要数据库?

many-to-many - Entity Framework 4 多对多更新

templates - EF4 : Get the linked column names from NavigationProperty of an EDMX