I am using Oracle's managed ODP.NET client with Entity Framework. It's working fine. However I am having different behaviours in different servers. I am pretty sure it has something to do with DLL versions, but I could not find any differences so far.
I have these tables:
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)
);
And these entities:
public class Parent {
Int32 Id { get; set; }
string Data { get; set; }
}
public class Child {
Int32 Id { get; set; }
Parent Parent { get; set; }
}
This is the code:
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
I have a trigger automatically populating the id
on both (parent and child), and I am using Store Generated Pattern = Identity
on the entity framework configuration.
My issue is:
On my dev machine, it works perfectly as expected. Both rows are inserted on their respective tables. However, on the Server, I am getting an error saying: The specified value is not an instance of type 'Edm.Decimal'
.
More info:
Oracle.ManagedDataAccess (v 4.121.1.0) Entity Framework (v v4.0.30319.1)
On both: dev machine (working) + server (not working).
Ideas?
Trying changing the definition of your Id
column from Int32
to Decimal
. I've had this problem several times and I think that fixed it.
public class Parent {
Decimal Id { get; set; }
string Data { get; set; }
}
public class Child {
Decimal Id { get; set; }
Parent Parent { get; set; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With