moozzyk/EFInteractiveViews

MappingViewCacheFactory is already set and cannot be modified.

Closed this issue · 2 comments

Hi all.
I'am try to use this library with EF 6.1.3 and MVC5 and when I run the Action the first time everything is ok but when y make another request to the same Action Controller that exception comes.

An example of my code:

           using (var ctx = new Context())
            {
                InteractiveViews
                    .SetViewCacheFactory(ctx, new FileViewCacheFactory(@"D:\MyViews.xml"));
                watch.Start();
                var list = await ctx.Specifications.Take(100).ToListAsync();
                watch.Stop();
                System.Diagnostics.Debug.WriteLine(watch.Elapsed);
                return View(list);
            }

Regards

EF does not allow setting the view cache factory multiple times. Setting it after sending the first query is futile since it's already after all the work has been done. I typically recommend setting the factory in a static ctor or code that runs once when the application starts.

Thank you moozzyk. My mistake. Yesterday i read the documentation and everything works ok.