Question

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?

Était-ce utile?

La solution

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; }
}

Autres conseils

Installing .Net 4.5 should fix this problem as identified on this Microsoft forum. I experienced the same issue were the calls worked fine on a dev machine but failed in production and, even though my project was targeting .net 4, installing .net 4.5 solved the issue.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top