Click here to Skip to main content
15,884,176 members
Home / Discussions / C#
   

C#

 
AnswerRe: Want place code logic in class using Inno setup PinPopular
Pete O'Hanlon24-Jun-14 20:40
mvePete O'Hanlon24-Jun-14 20:40 
GeneralRe: Want place code logic in class using Inno setup Pin
Ashfaque Hussain24-Jun-14 22:00
Ashfaque Hussain24-Jun-14 22:00 
QuestionCreate Microsoft Excel in C# Pin
Jassim Rahma24-Jun-14 20:22
Jassim Rahma24-Jun-14 20:22 
AnswerRe: Create Microsoft Excel in C# Pin
Kornfeld Eliyahu Peter24-Jun-14 20:29
professionalKornfeld Eliyahu Peter24-Jun-14 20:29 
AnswerRe: Create Microsoft Excel in C# Pin
Richard Deeming25-Jun-14 1:32
mveRichard Deeming25-Jun-14 1:32 
SuggestionRe: Create Microsoft Excel in C# Pin
LucasRLS25-Jun-14 1:57
LucasRLS25-Jun-14 1:57 
AnswerRe: Create Microsoft Excel in C# Pin
Nguyen.H.H.Dang25-Jun-14 18:45
professionalNguyen.H.H.Dang25-Jun-14 18:45 
QuestionDbContext recreate with cache clear Pin
Nathan Minier24-Jun-14 3:25
professionalNathan Minier24-Jun-14 3:25 
I'm trying to get my web application to reload a DbContext cache after initialization to introduce new entities (if available, as introduced via MEF) into the context model. Currently the context populates via an OnModelCreating overload.
C#
public class MyContext : DbContext
    {
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            var models = DependencyResolver.Current.GetServices(typeof(IModel));
            foreach (var model in models)
            {
                var entityMethod = typeof(DbModelBuilder).GetMethod("Entity");
                entityMethod.MakeGenericMethod(model.GetType())
                    .Invoke(modelBuilder, new object[] { });
            }
        }

I use a custom initializer that will add entities as appropriate on initilization ( I'm working on an archive for entity removal, but that's another topic).

My issue is this: I would like to dynamically load modules, have the context pick-up the IModel objects immediately and make them available for use. Does anyone know of a hook that will allow me to re-initialize the context and clear the cache without a complete application restart?

Note: I don't want to disable the cache completely, as this will not be an overly common task and it does offer more benefit than this functionality is worth.
AnswerRe: DbContext recreate with cache clear Pin
Dave Kreskowiak24-Jun-14 5:04
mveDave Kreskowiak24-Jun-14 5:04 
GeneralRe: DbContext recreate with cache clear Pin
Nathan Minier24-Jun-14 5:52
professionalNathan Minier24-Jun-14 5:52 
GeneralRe: DbContext recreate with cache clear Pin
Dave Kreskowiak24-Jun-14 6:00
mveDave Kreskowiak24-Jun-14 6:00 
GeneralRe: DbContext recreate with cache clear Pin
Nathan Minier24-Jun-14 6:22
professionalNathan Minier24-Jun-14 6:22 
GeneralRe: DbContext recreate with cache clear Pin
Dave Kreskowiak24-Jun-14 6:54
mveDave Kreskowiak24-Jun-14 6:54 
GeneralRe: DbContext recreate with cache clear Pin
Nathan Minier24-Jun-14 9:49
professionalNathan Minier24-Jun-14 9:49 
QuestionProgramming Visio streams on a local computer and hosted on a remote server using c# Pin
orélle23-Jun-14 22:25
orélle23-Jun-14 22:25 
AnswerRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Kornfeld Eliyahu Peter23-Jun-14 22:38
professionalKornfeld Eliyahu Peter23-Jun-14 22:38 
GeneralRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
orélle23-Jun-14 23:20
orélle23-Jun-14 23:20 
AnswerRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Kornfeld Eliyahu Peter23-Jun-14 23:23
professionalKornfeld Eliyahu Peter23-Jun-14 23:23 
GeneralRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
orélle24-Jun-14 1:03
orélle24-Jun-14 1:03 
AnswerRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Kornfeld Eliyahu Peter24-Jun-14 1:21
professionalKornfeld Eliyahu Peter24-Jun-14 1:21 
GeneralRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
orélle24-Jun-14 2:20
orélle24-Jun-14 2:20 
AnswerRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Kornfeld Eliyahu Peter24-Jun-14 2:29
professionalKornfeld Eliyahu Peter24-Jun-14 2:29 
GeneralRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Dave Kreskowiak24-Jun-14 1:39
mveDave Kreskowiak24-Jun-14 1:39 
SuggestionRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Richard Deeming24-Jun-14 0:38
mveRichard Deeming24-Jun-14 0:38 
GeneralRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
OriginalGriff24-Jun-14 1:06
mveOriginalGriff24-Jun-14 1:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.