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; }
}