5

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?

Tom Halladay
  • 5,651
  • 6
  • 46
  • 65
Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
  • I too am having the same problem. My QA server deployment is fine, but my Production one is not working. I have my type size set to Number(20) and my .NET type as long. So weird and the suggestions so far to change to decimal don't make sense to me since it does work in certain environments. FYI, will read, just not insert or update. – CameronP Nov 28 '14 at 20:56

2 Answers2

4

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; }
}
Tom Halladay
  • 5,651
  • 6
  • 46
  • 65
0

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.

Code Ranger
  • 401
  • 3
  • 7