Possible to access DbConfiguration from DbContext?

.net c# entity-framework entity-framework-6

Question

Having my own configuration class that is inherited from my own EF DbContext class:

[DbConfigurationType(typeof(MyDbConfiguration))]
public class MyDbContext : DbContext
{
}

I'm attempting to connect to the instance ofMyDbConfiguration internal toMyDbContext .

(Presuming that there is in fact any case at all.)

E.g.:

public class MyDbConfiguration : DbConfiguration
{
    public int SomeProperty { get; set; }
}

and

[DbConfigurationType(typeof(MyDbConfiguration))]
public class MyDbContext : DbContext
{
    public int SomeMethod()
    {
        // This lines fails to compile:
        var config = (MyDbConfiguration)Configuration;

        config.SomeProperty = 42;
    }
}

The coding mistake is:

Cannot convert type 'System.Data.Entity.Infrastructure.DbContextConfiguration' to 'MyDbConfiguration'.

There is obviously no connection between these two categories.

My Entity Framework setup stuff is probably utterly above my comprehension, and this inquiry is a Problem XY. Still, I'm politely attempting to ask:

My inquiry

Is it possible to access theDbConfiguration coming from aDbContext ?

If not, is the reverse scenario conceivable? hence, access theDbContext coming from aDbConfiguration ?

(This inquiry is associated with 14th EFCache problem)

1
3
7/20/2017 1:30:37 PM

Accepted Answer

ZZZ_tmp
0
7/20/2017 1:32:33 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow