The specified value is not an instance of type 'Edm.Decimal'

The specified value is not an instance of type 'Edm.Decimal'

Postby aph » Wed 22 Oct 2008 13:18

We are building an application with support for SQL and Oracle. There is one shared conceptual model, and one store model/one mapping model with DB-specific code. Everything is working fine with SQL, but I have an issue with the Oracle provider that I am not able to solve. I'm not quite sure how much it has to do with this Oracle provider, but I don't know where to ask else.

For one table has a primary key as int in SQL and as number in Oracle. In conceptual model, the primary key column is Int32, it works fine with SQL. For oracle, query data works just fine, but when add a record and save the change, I will get this exception:

The specified value is not an instance of type 'Edm.Decimal'
Parameter name: value

at System.Data.Mapping.Update.Internal.TableChangeProcessor.CompileCommands(ChangeNode changeNode, UpdateCompiler compiler)
at System.Data.Mapping.Update.Internal.UpdateTranslator.d__0.MoveNext()
at System.Linq.Enumerable.d__71`1.MoveNext()
at System.Data.Mapping.Update.Internal.UpdateCommandOrderer..ctor(IEnumerable`1 commands, UpdateTranslator translator)
at System.Data.Mapping.Update.Internal.UpdateTranslator.ProduceCommands()
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
at System.Data.Objects.ObjectContext.SaveChanges(Boolean acceptChangesDuringSave)
at System.Data.Objects.ObjectContext.SaveChanges()
at Bottomline.Transform.Foundation.AuditingData.DataAccess.EntityFramework.AuditDataAccess.Add(IAuditRecord record)


Here are the schemas for my model:

Store:




decimal" Nullable="false" Scale="0" />
decimal" Nullable="false" Precision="22" Scale="0" />
decimal" Nullable="false" Scale="0" />
decimal" />







Conceptual:




Int32" Nullable="false" />
Int32" Nullable="false" />
Int32" Nullable="false" />
Int32" />








Mapping:
















If I change the primary key (AUDITID) to Decimal in conceptual model and other IDs keep same as Int32, it works fine. I can create and save a record.

Since these Ids are int in SQL, they can not be mapped to Decimal for SQL.

Hopefully someone can help me out on this one.
aph
 
Posts: 2
Joined: Wed 22 Oct 2008 12:58

Postby Shalex » Wed 22 Oct 2008 15:14

Type should be set to "int" in the file that stores the SSDL part for Oracle. If column data is stored as NUMBER(9), EDM Wizard will set immediately the Type="Int32" type, corresponding to it.

Store:




int
" Nullable="false" Scale="0" />
int" Nullable="false" Precision="22" Scale="0" />
int" Nullable="false" Scale="0" />
int" />





Shalex
Devart Team
 
Posts: 7530
Joined: Thu 14 Aug 2008 12:44

Postby aph » Wed 22 Oct 2008 22:08

Thanks. I was using NUMBER as column data type.
aph
 
Posts: 2
Joined: Wed 22 Oct 2008 12:58

Share conceptual model

Postby marcos » Fri 07 Nov 2008 18:56

Aph,

I´m building an application with the same concept. It must support SQL Server and Oracle. How can I share a conceptual model within two store/mapping models? Have you used two .edmx files?

Thanks in advance,
Marcos
marcos
 
Posts: 2
Joined: Fri 07 Nov 2008 18:49

Postby Shalex » Mon 10 Nov 2008 11:59

Marcos,

If you need the same conceptual/mapping models when working with SQL Server and Oracle, you need 4 files: 2 common files with CSDL part and MSL part, the SSDL file with provider specific code for SQL Server and the SSDL file with provider specific code for Oracle.

We recommend you the following. Generate 2 .edmx files - one for SQL Server, another for Oracle. If their CSDL parts are the same, place the CSDL part in the separate file. Check the MSL parts; probably, you will need to edit a bit manually to get the result common MSL part. Move the MSL part to the separate file. The SSDL parts of original .edmx files should be placed in the separate files also.

Please look through the sample ( http://code.msdn.microsoft.com/EFQuerySamples ) for detailed information.
Shalex
Devart Team
 
Posts: 7530
Joined: Thu 14 Aug 2008 12:44

Postby marcos » Mon 10 Nov 2008 16:23

Thanks a lot Shalex!

Regards,
Marcos
marcos
 
Posts: 2
Joined: Fri 07 Nov 2008 18:49

Postby robymes » Wed 12 Nov 2008 10:23

just an hint: if you are using stored procedure mapping, you have to consider 2 different MSL files because of the different syntax between SQL Server and Oracle.
robymes
 
Posts: 29
Joined: Tue 09 Sep 2008 09:46

Support for Edm.Boolean

Postby jtucholski2 » Fri 17 Apr 2009 12:12

I'm getting the error

error 2019: Member Mapping specified is not valid. The type 'EdmBoolean[Nullable=false,DefaultValue=] of member 'IsDefault' in type 'TypeX' is not compatible with 'Devart.Data.Oracle.decimal[Nullable=false,DefaultValue=0,Precision=1,Scale=0]

I tried using the NUMBER data type with a precision of 1, scale of 0, but NUMBER is not recognized.

Which ssdl type do I need for conversion from boolean to oracle data type?
jtucholski2
 
Posts: 6
Joined: Mon 06 Apr 2009 20:51

Postby AndreyR » Fri 17 Apr 2009 13:24

If you have a NUMBER(1) field in database, it should be automatically converted to "bool" in the SSDL part of .edmx file.
If it was not, you can change it manually. Don't forget to remove precision and scale.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Using Number data type

Postby jtucholski2 » Fri 17 Apr 2009 14:52

I tried using the number data type. I can't regenerate the model from the oracle schema at the moment, but would expect the below line to validate in my SSDL:



The error that I get when running ValidateArtifacts against this is

error 0040: The Type number is not qualified with a namespace or alias. Only PrimitiveTypes can be used without qualification.

Any idea why it isn't recognizing the number data type?
jtucholski2
 
Posts: 6
Joined: Mon 06 Apr 2009 20:51

Postby jtucholski2 » Mon 20 Apr 2009 13:16

Good thing I came back and read this. I didn't realize that you said it would be bool in the SSDL. Thanks.
jtucholski2
 
Posts: 6
Joined: Mon 06 Apr 2009 20:51


Return to dotConnect for Oracle