Compatibility with EF 6 /MVC 5 / .NET 4.5.1

Oct 27, 2013 at 6:22 AM
Hi,
I'm migrating my projects to Visual Studio 2013, .NET Framework 4.5.1, EF 6 and ASP.NET MVC 5.
So far, so good, except for a single glitch:

On the default NO SystemController, I'm getting an exception.
The code:
protected override void OnActionExecuting(ActionExecutingContext filterContext) {
    if (Request.Browser.Type.ToUpper() == "IE6" || Request.Browser.Type.ToUpper() == "IE7") {
        filterContext.Result = View("BrowserError");
        return;
    }

    base.OnActionExecuting(filterContext);
}
I'm getting:

Method not found: 'System.Data.Objects.ObjectContext System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: Method not found: 'System.Data.Objects.ObjectContext System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()'.

Source Error:


Line 59: }
Line 60:
Line 61: base.OnActionExecuting(filterContext);
Line 62: }
Line 63: }

Stack Trace:


[MissingMethodException: Method not found: 'System.Data.Objects.ObjectContext System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()'.]
NakedObjects.EntityObjectStore.LocalContext..ctor(CodeFirstEntityContextConfiguration config) +0
NakedObjects.EntityObjectStore.EntityObjectStore.ResetCodeOnlyContext(CodeFirstEntityContextConfiguration codeOnlyConfig) +95

[InitialisationException: Failed to create Code First DbContext]
NakedObjects.EntityObjectStore.EntityObjectStore.ResetCodeOnlyContext(CodeFirstEntityContextConfiguration codeOnlyConfig) +209
NakedObjects.EntityObjectStore.EntityObjectStore.ResetContext(KeyValuePair2 kvp) +385
System.Linq.Enumerable.ToDictionary(IEnumerable
1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) +370
System.Linq.Enumerable.ToDictionary(IEnumerable
1 source, Func2 keySelector, Func2 elementSelector) +90
NakedObjects.EntityObjectStore.EntityObjectStore.Reset() +334
NakedObjects.Persistor.Objectstore.ObjectStorePersistor.Reset() +154
NakedObjects.Core.Context.HttpContextContext.EnsureContextReady() +194
NakedObjects.Core.Context.NakedObjectsContext.EnsureReady() +55
NakedObjects.Web.Mvc.Controllers.NakedObjectsController.OnActionExecuting(ActionExecutingContext filterContext) +41
SmsAPI.Controllers.SystemController.OnActionExecuting(ActionExecutingContext filterContext) in e:\Users\Ury.Ury-PC\Projects\LiveNetIl\SMS\SmsAPI\Controllers\SystemController.cs:61
System.Web.Mvc.Async.AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive(Int32 filterIndex) +296
System.Web.Mvc.Async.<>c__DisplayClass30.<BeginInvokeActionMethodWithFilters>b__2e(AsyncCallback asyncCallback, Object asyncState) +112
System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +150
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate
1 endDelegate, Object tag, Int32 timeout) +132
System.Web.Mvc.Async.<>c__DisplayClass1e.<BeginInvokeAction>b__16(AsyncCallback asyncCallback, Object asyncState) +1449
System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +150
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate
1 endDelegate, Object tag, Int32 timeout) +96
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +408
System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +45
System.Web.Mvc.Async.WrappedAsyncVoid1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +111
System.Web.Mvc.Async.WrappedAsyncResultBase
1.Begin(AsyncCallback callback, Object state, Int32 timeout) +150
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate1 beginDelegate, EndInvokeVoidDelegate1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +203
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +895
System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +150
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate
1 beginDelegate, EndInvokeVoidDelegate1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +154
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +527
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__3(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +108
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +111
System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +150
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate
1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +203
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +681
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12270483
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288


It looks like an EF interface has changed in EF6. Can something be done, or should I revert to EF5?

Thanks,
Ury
Coordinator
Oct 27, 2013 at 7:01 PM
Microsoft introduced some big structural changes with EF6 - they don't have much impact on domain code (although you will have to remove the System.Data.Entity.dll from your domain projects), but they do have a significant impact on frameworks like ours. We already have a ticket to move up to EF 6, and now that it has finally been released this is high on our priority list. But for the time being you should stick to EF5.
Oct 30, 2013 at 6:38 AM
Understood, thanks Richard,
Coordinator
Nov 21, 2013 at 11:43 AM
Update:

Ury, we made a substantial start on this upgrade, but it proved to be much more involved than we had hoped. So we have formally now created two branches, a 5.6 branch (which will be the next release, and will still be on .NET 4.5, MVC 5 and EF 5) and a 6.0 branch (which uses the new stack). Work on the latter has been temporarily suspended while we deal with some more pressing issues on the 5.6 branch.
Nov 30, 2013 at 9:03 AM
Hi Richard,
Thanks for the update.
I'll focus on the API functionality of my project and try to hold back the Web UI project until there are developments with the NO 6.0 branch.
Best regards,
Ury


Jan 9, 2014 at 3:58 PM
Good Morning all,
    I would appreciate  knowing when this is resolved as well. I am writing my first MVC 5 web site and having the same trouble.
Coordinator
Jan 14, 2014 at 1:42 PM
We are committed to moving up to .NET 4.5, MVC 5 and EF 5, but I'm afraid I can't specify a date. That release will be NOF 6.0 (which is already a branch on the source repository, but is incomplete). There might be one more release (5.7) under the current stack, yet.

Make sure you are on our mailing list, so that you get automatically notified of new releases.