column of type number(10,0) is mapped to .NET type 'long' and not 'int'

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
devartRR
Posts: 4
Joined: Tue 02 Jun 2015 06:02

column of type number(10,0) is mapped to .NET type 'long' and not 'int'

Post by devartRR » Tue 02 Jun 2015 06:24

I am converting a SQL db to Oracle. The SQL columns of type 'int' are converted to Oracle data types of Number(10,0).
I am using dotConnect for Oracle 'Entity Developer' to generate my Entities (EF6) in VS2013. The idea is to use the existing .NET code to use entities generated from Oracle DB. As long as Entities are same, the code should.
The issue is that when I use Entity Developer to generate Entities from the Oracle DB, the corresponding class properties are generated as .NET type of 'long' and not 'int'. So for USER table, USER_ID property is generated as .NET type 'long'.

I have lot of .NET code (c#) going against EF generated from the SQL server, where all the properties corresponding to datatype of SQL 'int' were mapped to .NET type of 'int'. So the existing code like this fails : int _userid = USER.USER_ID; //compiler error.

So the question is - is there a way to tell 'Entity developer' to make any property corresponding to Oracle Datatype 'number(10,0)' as .NET type 'int' and not 'long'?

Hope that is clear.

Thanks

Devartuser.

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: column of type number(10,0) is mapped to .NET type 'long' and not 'int'

Post by Shalex » Tue 02 Jun 2015 10:20

devartRR wrote:is there a way to tell 'Entity developer' to make any property corresponding to Oracle Datatype 'number(10,0)' as .NET type 'int' and not 'long'?
The Database First mapping for the newly created *.edml models can be customized via Visual Studio > Tools > Entity Developer > Options > Server Options > Oracle.

JIC: do you have an existing *.edmx model? If yes, you can convert it to *.edml.
Assuming that dotConnect for Oracle Professional is already installed on your workstation, here is a recommended way of converting *.edmx (System.Data.SqlClient) to *.edml (Devart.Data.Oracle):
  • a) install Entity Developer Professional Trial for migrating (you can uninstall it after the migration is done, it is needed because it supports System.Data.SqlClient your model was originally created for)
  • b) create a new user (schema) in your Oracle server
  • c) open your existing *.edmx model in Entity Developer
  • d) change provider to Devart.Data.Oracle via Database Explorer and set the connection string to Oracle server
  • e) right click on designer surface > Regenerate Storage and Mapping
  • f) right click on designer surface > Update Database From Model
  • g) right click on the Templates node in Model Explorer > New template and choose the needed template
  • h) save model (as *.edml). Entity Developer allows only to import *.edmx but the output would be *.edml. Output can not be *.edmx because Entity Developer uses extra tags and attributes, additional features which are not supported by EDM Designer. This question was discussed at http://forums.devart.com/viewtopic.php?f=32&t=24766
  • i) set naming rules to have names in *.edml like the ones in *.edmx
That's all. Now you can uninstall Entity Developer as a separate tool. dotConnect for Oracle Professional includes its own Entity Developer which can be used only with Devart.Data.Oracle.

Post Reply