Search code examples
oracleentity-frameworkmappingdecimaldevart

devart oracle 9.3- entity framework 7 ( or core 1) Mapping can't recognize decimal at visual studio 2017


I am working on a .Net Core class library project.I use Devart entity framework core to connect oracle database. I use devart's oracle mapping methods at link http://blog.devart.com/entity-framework-core-1-entity-framework-7-support.html

I can get datas successfully when type of columns of table is string. But, if type of columns of table is decimal, complier gives me error below:

Severity    Code    Description Project File    Line    Suppression State
Error   CS0452  The type 'decimal?' must be a reference type in order to use it as parameter 'TEntity' in the generic type or method 'OraclePropertyBuilderExtensions.ForOracleHasColumnName<TEntity>(PropertyBuilder<TEntity>, string)'.

my mapping function is:

 private void MyTableMapping(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<MyTable>().ForOracleToTable(@"MyTable");
            modelBuilder.Entity<MyTable>().Property<string>(x => x.SIRKETID).ForOracleHasColumnName(@"SIRKET_ID").ForOracleHasColumnType(@"VARCHAR2").ValueGeneratedNever().HasMaxLength(2);//this  line is ok
            modelBuilder.Entity<MyTable>().Property<decimal>(x => x.ID).ForOracleHasColumnName(@"ID").ForOracleHasColumnType(@"NUMBER").IsRequired().ValueGeneratedOnAdd();//this  line gives error
         }

Sorry for my low English.


Solution

  • Thank you for your report. We have reproduced the issue and will notify you when it is fixed.

    As a workaround, please use:

    optionsBuilder.UseOracle("oracle_connection_string");
    modelBuilder.Entity<MyTable>().Property<decimal>(x => x.ID).HasColumnName(@"ID").HasColumnType(@"NUMBER").IsRequired().ValueGeneratedOnAdd();