Convert Int32 to Oracle number(5) with EF4

c#-4.0, entity-framework-4, oracle

Solution

I found how to remove the error.

I edited the edmx file in xml mode, found my field in the ssdl section :

<Property Name="SIT_INSEE" Type="number" Precision="5" />

I removed the `Precision="5"` and the warning disappeared.

Problem

I am using EF 4 (database first, model fully generated from it) with an oracle 10g database and I have a problem with one field. My field is defined as a `NUMBER(5)` in my database. In my model, EF has defined it as a `short`. My problem is that i have some values that are greater than 32,767 (max of a short) I found this post : Entity Framework generates short instead of int. I follow the instruction and it works, my model contain now Int32 values. But I have a new problem : ``` Error 2019: Member Mapping specified is not valid. The type 'Edm.Int32[Nullable=True,DefaultValue=]' of member 'XX' in type 'Model.XXX' is not compatible with 'OracleEFProvider.number[Nullable=True,DefaultValue=,Precision=5,Scale=0]' of member 'XX' in type 'Model.Store.XXX'. ``` This error is always show in the Error List tab of Visual Studio. However, the build success, and it half works: - read a value in database works - write a value do not work : 99999 was transformed in -31073 (see edit) Is there a solution to have it works on both ways ? BTW, is there any way to tell entity to use int32 for oracle INTEGER fields ? It use decimal by default. EDIT While debuging step by step, I found why my value was -31073. I forgot this line : ``` dao.Value = (short)dto.Value; ``` My two values were int, but the implicit conversion in short was the origin.

Original source

Related problems