i have a problem with the generated code from Entity Developer and dotconnect oracle.
After generation of the context class there is the following code generated:
Code: Select all
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
if (!optionsBuilder.Options.Extensions.OfType<RelationalOptionsExtension>().Any(ext => !string.IsNullOrEmpty(ext.ConnectionString) || ext.Connection != null))
optionsBuilder.UseOracle(@"User Id=*****;Password=*****;Server=****;Direct=True;Service Name=orcl;Persist Security Info=True);
}
CustomizeConfiguration(ref optionsBuilder);
base.OnConfiguring(optionsBuilder);
}
System.InvalidOperationException: No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.
This is because the optionsBuilder.IsConfigured is true.
So the optionsBuilder.UseOracle(...) is never reached.
Why does the optionsBuilder.IsConfigured is true?
What is the best way to get this to work?
For sure i can delete the if (!optionsBuilder.IsConfigured) after every generation but i think thats not the right way?!
Thanks for any help
Kind Regards
Thomas