Pab*_*ruz 5 oracle entity-framework odp.net entity-framework-4 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)
);
Run Code Online (Sandbox Code Playgroud)
而这些实体:
public class Parent {
Int32 Id { get; set; }
string Data { get; set; }
}
public class Child {
Int32 Id { get; set; }
Parent Parent { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是代码:
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
Run Code Online (Sandbox Code Playgroud)
我有一个触发器自动填充id两者(父和子),我Store Generated Pattern = Identity在实体框架配置上使用.
我的问题是:
在我的开发机器上,它按预期完美地工作.两行都插在各自的表中.但是,在服务器上,我收到一个错误说:The specified value is not an instance of type 'Edm.Decimal'.
更多信息:
Oracle.ManagedDataAccess(v 4.121.1.0)实体框架(v 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; }
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1068 次 |
| 最近记录: |