Server Error in '/' Application.

The context cannot be used while the model is being created. This exception may be thrown if the context is used inside the OnModelCreating method or if the same context instance is accessed by multiple threads concurrently. Note that instance members of DbContext and related classes are not guaranteed to be thread safe.

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.InvalidOperationException: The context cannot be used while the model is being created. This exception may be thrown if the context is used inside the OnModelCreating method or if the same context instance is accessed by multiple threads concurrently. Note that instance members of DbContext and related classes are not guaranteed to be thread safe.

Source Error:


Line 16:             <div class="bgPageNews col-xs-12">
Line 17: 
Line 18:                 @Html.Raw(DKSOFT.CODE.MVC4.Interface.ICategory.Renderbreadcrumb(Model.CategoryID))
Line 19: 
Line 20:                 <div class="detailnewspage col-xs-12">

Source File: c:\Domains\lawdaohue.com.vn\httpdocs\Views\News\NewsDetail.cshtml    Line: 18

Stack Trace:


[InvalidOperationException: The context cannot be used while the model is being created. This exception may be thrown if the context is used inside the OnModelCreating method or if the same context instance is accessed by multiple threads concurrently. Note that instance members of DbContext and related classes are not guaranteed to be thread safe.]
   System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +1110
   System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +25
   System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +69
   System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +21
   System.Data.Entity.Internal.Linq.InternalSet`1.Find(Object[] keyValues) +32
   DKSOFT.CODE.MVC4.Interface.ICategory.Renderbreadcrumb(Nullable`1 CategoryID) +131
   ASP._Page_Views_News_NewsDetail_cshtml.Execute() in c:\Domains\lawdaohue.com.vn\httpdocs\Views\News\NewsDetail.cshtml:18
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +255
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +158
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +88
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +108
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +371
   System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +31
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +434
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +632
   System.Web.Mvc.Controller.ExecuteCore() +144
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +93
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +25
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +53
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +41
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +53
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +431
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +75
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +158


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4494.0