We are using MEF to customize certain functionality of our ASP MVC application. We are using .NET 4.0, and SQL Server 2008. We have run into some very strange behavior when using EF4 and a LINQ statement to a view inside a MEF assembly.
The code below will timeout when executed as part of the imported assembly using MEF.
It will run in less than a second when it is pulled out and executed in the main assembly.
If the date range is set to one day the MEF implementation will eventually finish in about 15 seconds.
If we use a table instead of a view it will work fine in the MEF implementation <1 sec.
The code below and the view works flawlessly everywhere except when executed inside the MEF code.
Does MEF introduce any special limitations or problems when EF4 is used in a MVC Web application? We can find a work-around to this problem, but I'd like to know if this is a symptom that we are using MEF wrong?
DateTime startDate = DateTime.Now.AddDays(-30);
DateTime endDate = DateTime.Now;
var _Items = dto.ClientContext.vwItemLists.Where(c => c.CreatedOn > startDate && c.CreatedOn <= endDate);
_context.TotalItemsMatched = _Items.Count();