I executed the following snipped of code.:
var command = new OracleCommand();
command.Connection = connection;
command.CommandText = "select * from \"Customer\"";
command.CommandType = CommandType.Text;
var reader = command.ExecuteReader();
One of the Customer columns is a number(10). I read in odp .net developer guide that number(10) should map to Int32 by default and that is not what i get. Number(10) is mapping to Int64 and number(19) to decimal (should map to int64 by default according to the developer guide). I tried to use custom edm mappings, but it is also not working. Here is my custom mappings:
<add name="bool" value="edmmapping number(1,0)" />
<add name="byte" value="edmmapping number(3,0)" />
<add name="int16" value="edmmapping number(4,0)" />
<add name="int32" value="edmmapping number(10,0)" />
<add name="int64" value="edmmapping number(19,0)" />
Your code snippet does not look like using Entity Framework (EF).
The custom type mapping is for Entity Data Model (EDM).
When you use the ADO.NET Entity Data Model wizard, the mapping
will be applied to the generated data model.
Please give it a try.
I believe your question is about the precision and scale checking in OracleDataReader GetInt16, GetInt32, and GetInt64 methods.
Only EF-related OracleDataReader objects will not use column metadata in the checking in said methods.
Note: The latest version must have removed EF-related condition. It won't use column metadata in the checking in said methods
as long as it's .NET 4.0.
Edited by: shsu on Sep 19, 2012 4:37 PM
I think your situaion may be like following post: ODAC 126.96.36.199 incorrect EDM mapping
Where SqlQuery() is used to execute a query that is not generated from a LINQ query.
When the column is a key column, you may get the said exception.
The fix for bug 14642733 should address this issue.