Base solution for your next web application
Open Closed

Info for oracle DB users #99


User avatar
0
daws created

Hello ABP community,

For who it might be interested, i'm using abp & Module Zero with Oracle.

I Had a few trouble since I was using DatabaseFirst before and not CodeFirst Generation.

If you are stuck, there is some tips :

  • nuget package is the official odp.net from oracle : <a class="postlink" href="https://www.nuget.org/packages/Oracle.ManagedDataAccess.EntityFramework/12.1.21">https://www.nuget.org/packages/Oracle.M ... rk/12.1.21</a>
  • you need to delete ALL migrations files from CodeFirst & regenerate only ONE file (via add-migration). The reason is ODP.NET does not manage well dbmigration queries as "alter column" and annotions changes.
  • you need to map column types in your web config, to match .NET type to oracle type : my current mapping is :
<oracle.manageddataaccess.client>
    <version number="*">
      <dataSources>
        <dataSource alias="TESTWEB" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.1.25.11)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=TEST))) " />
      </dataSources>
      <edmMappings>
        <edmMapping dataType="number">
          <add name="bool" precision="1" />
          <add name="byte" precision="3" />
          <add name="int16" precision="5" />
          <add name="int32" precision="10" />
          <add name="int64" precision="19" />
        </edmMapping>
      </edmMappings>
    </version>
  </oracle.manageddataaccess.client>

With all theses infos, code first works fine with oracle and you can create & seed infos via Module Zero.


3 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Thank you very much for information sharing :)

  • User Avatar
    0
    worthyvii created

    This seems impossible because MZ includes a field which is over 30 chars long, which Oracle won't allow. Can you confirm if you're gonna change this hikalkan?

  • User Avatar
    0
    worthyvii created

    In response to my previous message, here is the solution to avoid the 32 character name limit in Oracle. Add this to your DbContext class.

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
    
                modelBuilder.HasDefaultSchema("ORACLEUSERINCAPITALLETTERS");
    
                //short oracle names
                modelBuilder.Entity<NotificationSubscriptionInfo>()
                    .Property(t=>t.EntityTypeAssemblyQualifiedName)
                    .HasColumnName("EntityTypeAssQualName");
    
    
                modelBuilder.Entity< NotificationInfo >()
                    .Property(t => t.EntityTypeAssemblyQualifiedName)
                    .HasColumnName("EntityTypeAssQualName");
    
    
                modelBuilder.Entity<NotificationInfo>()
                    .Property(t => t.EntityTypeAssemblyQualifiedName)
                    .HasColumnName("EntityTypeAssQualName");
    
                modelBuilder.Entity<TenantNotificationInfo>()
                    .Property(t => t.EntityTypeAssemblyQualifiedName)
                    .HasColumnName("EntityTypeAssQualName");
    ...