Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Set Oracle Configuration Settings in EF Core DBContext

user613363Feb 7 2020 — edited Feb 8 2020

I am using Oracle.EntityFramework.Core 2.19.50. UPDATE: I have learned a few things.  I have put most of the configurations in the Startup.cs file.

This is how I did it in Oracle.Managed.EntityFramework:

    using System.Data.Entity;

    public class AppsDbContext : DbContext

    {

        public AppsDbContext()

            : base("name=AppsDbContext")

        {

            this.Configuration.AutoDetectChangesEnabled = false;

            this.Configuration.LazyLoadingEnabled = false;

            this.Configuration.ProxyCreationEnabled = false;

            this.Configuration.UseDatabaseNullSemantics = true;

            this.Configuration.ValidateOnSaveEnabled = false;

            Database.SetInitializer<AppsDbContext>(null);

         

        }

        public DbSet<AppsAccess> AppsAccessData { get; set; }

        public DbSet<EmployeeAccess> EmployeeAccess { get; set; }

     

        protected override void OnModelCreating(DbModelBuilder modelBuilder)

        {

            modelBuilder.HasDefaultSchema("XYZ");                

        }    

    }

}

For EF Core:

Startup.cs

services.AddEntityFrameworkOracle()

    .AddDbContext<OracleDbContext>(builder => builder

     .UseOracle(Configuration["Data:OracleDbContext"],providerOptions => providerOptions.CommandTimeout(60).UseRelationalNulls(true).MinBatchSize(2))

     .EnableDetailedErrors(false).EnableSensitiveDataLogging(false)

     .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking),ServiceLifetime.Scoped);

OracleConfiguration.StatementCacheSize = 300;

OracleConfiguration.FetchSize = 300000;

:

Here's my DbContext:

using Microsoft.EntityFrameworkCore;

public class AppsDbContext : DbContext

    {

        public AppsDbContext(DbContextOptions<AppsDbContext> options): base(options)

        {

            this.ChangeTracker.LazyLoadingEnabled = false;          

        }

         public AppsDbContext() {

            this.ChangeTracker.LazyLoadingEnabled = false;          

        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

        {

            optionsBuilder.UseOracle(connectionString: "myconnectioninfo");

        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)

        {

            modelBuilder.HasDefaultSchema("ZZZ");

        }

        public DbSet<AppsAccess> AppsAccess { get; set; }

        public DbSet<EmployeeAccess> EmployeeAccess { get; set; }           

    }

This post has been answered by Alex Keh-Oracle on Feb 8 2020
Jump to Answer

Comments

user10211043

Unfortunately The 64 Bit file is not downloadable (404)

wget http://mysql-udf-http.googlecode.com/files/lib_mysqludf_json-x86_64.tar.gz
--2021-05-07 14:25:09-- http://mysql-udf-http.googlecode.com/files/lib_mysqludf_json-x86_64.tar.gz
Resolving mysql-udf-http.googlecode.com... 172.217.197.82, 2607:f8b0:400d:c0c::52
Connecting to mysql-udf-http.googlecode.com|172.217.197.82|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2021-05-07 14:25:10 ERROR 404: Not Found.

Thanks

Raghu

dvohra21

The file doesn't exist at the url. "The requested URL /files/lib_mysqludf_json-x86_64.tar.gz was not found on this server. "

1 - 3

Post Details

Added on Feb 7 2020
1 comment
6,959 views