Entity Framework 6. Disable ModelCaching

c# caching entity-framework entity-framework-6

Question

Okay, Google, I can't search for it. says Documentation

The model for that context is then cached and is for all further instances of the context in the app domain. This caching can be disabled by setting the ModelCaching property on the given ModelBuidler

confirms it, and SO. However, I am unable to accomplish it. I have to turn off caching since I only want to use one model to gather data from several log tables with the same structure.

logTableNames.ForEach(n =>
{
    using (var context = new LogContext(n))
    {
        Console.WriteLine($"Project: {n} -- {context.Logs.Count()} rows.\n");
    }
});

Get set up using

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.Entity<Log>().ToTable(_tableName);
}

However, the "OnModelCreating" function was only called once, and I was unable to change the table mapping. Perhaps there is a more effective technique to do my task?

1
2
5/23/2017 10:30:11 AM

Accepted Answer

ZZZ_tmp
2
8/23/2016 6:14:33 AM


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