我正在使用 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/