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:
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.
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.
Just to add my two cents in case anyone else is having similar problems. I noticed if you add the following to mappings in web.config and then recreate the edmx model from scratch (delete it and re-generate from database) it resolves some of these issues. Where simply adding the values to web.config resolved nothing (probably re-generating some of the code behind the scenes would be my guess).
<oracle.dataaccess.client>
<settings>
<add name="int32" value="edmmapping number(9,0)" />
</settings>
</oracle.dataaccess.client>
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