In a recent project we built a template based code generator to help us rapidly build out OData ASP.NET Api services over an existing Oracle database using Entity Framework. The first cut used a default mapping of decimal for each Oracle NUMBER(n, n) column found, and we started getting messages like the following:
Member Mapping specified is not valid. The type 'Edm.Decimal[Nullable=False,DefaultValue=,Precision=6,Scale=0]' of member 'Property' in type 'TypeName' is not compatible with 'OracleEFProvider.number[Nullable=False,DefaultValue=,Precision=6,Scale=0]' of member 'Column' in type 'CodeFirstDatabaseSchema.Table'.\r\n(469,12) : error 2019: Member Mapping specified is not valid.
Clearly just using the basic mapping was not correct!
In the Oracle data provider documentation it describes how the NUMBER(n, 0) data types map to various integer data types:
So it was easy to work out how we could use the scale and precision values to correct map the various NUMBER data types. What was pretty interesting to discover, however, is that you can change these mappings through config – the example given in the docs being to take a NUMBER(1, 0) column direct to a bool data type. Useful.