ASP.NET MVC 5

  • Thread starter Thread starter mainepaine
  • Start date Start date
M

mainepaine

Guest
Code to db workflow. Trying to query my db. When I use the below code I get the errors mentioned below?

public class CustomersController : Controller
{
private ApplicationDbContext _context;

public CustomersController()
{
_context = new ApplicationDbContext();
}

protected override void Dispose(bool disposing)
{
_context.Dispose();
}
}





Server Error in '/' Application.

Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

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.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Source Error:

Line 14: {
Line 15: _context = new ApplicationDbContext();
Line 16: }
Line 17:
Line 18: protected override void Dispose(bool disposing)


Source File: C:\Users\cdpai\Documents\SourceCodeWC\trunk\ASP.NET\03 Working with Data\EntityFramework\EntityFramework\Controllers\CustomersController.cs Line: 16

Assembly Load Trace: The following information can be helpful to determine why the assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' could not be loaded.

=== Pre-bind state information ===
LOG: DisplayName = EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
(Fully-specified)
LOG: Appbase = file:///C:/Users/cdpai/Documents/SourceCodeWC/trunk/ASP.NET/03 Working with Data/EntityFramework/EntityFramework/
LOG: Initial PrivatePath = C:\Users\cdpai\Documents\SourceCodeWC\trunk\ASP.NET\03 Working with Data\EntityFramework\EntityFramework\bin
Calling assembly : Microsoft.AspNet.Identity.EntityFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\cdpai\Documents\SourceCodeWC\trunk\ASP.NET\03 Working with Data\EntityFramework\EntityFramework\web.config
LOG: Using host configuration file: C:\Users\cdpai\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
LOG: Attempting download of new URL file:///C:/Users/cdpai/AppData/Local/Temp/Temporary ASP.NET Files/vs/7461f73a/4dfb86b1/EntityFramework.DLL.
LOG: Attempting download of new URL file:///C:/Users/cdpai/AppData/Local/Temp/Temporary ASP.NET Files/vs/7461f73a/4dfb86b1/EntityFramework/EntityFramework.DLL.
LOG: Attempting download of new URL file:///C:/Users/cdpai/Documents/SourceCodeWC/trunk/ASP.NET/03 Working with Data/EntityFramework/EntityFramework/bin/EntityFramework.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.


Stack Trace:

[FileLoadException: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
EntityFramework.Controllers.CustomersController..ctor() in C:\Users\cdpai\Documents\SourceCodeWC\trunk\ASP.NET\03 Working with Data\EntityFramework\EntityFramework\Controllers\CustomersController.cs:16

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +119
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
System.Activator.CreateInstance(Type type) +11
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +55

[InvalidOperationException: An error occurred when trying to create a controller of type 'EntityFramework.Controllers.CustomersController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +178
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +80
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +102
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +187
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +50
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +103
System.Web.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0() +26
System.Web.StepInvoker.Invoke(Action executionStep) +101
System.Web.<>c__DisplayClass4_0.<Invoke>b__0() +22
Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule.OnExecuteRequestStep(HttpContextBase context, Action step) +64
System.Web.<>c__DisplayClass284_0.<OnExecuteRequestStep>b__0(Action nextStepAction) +54
System.Web.StepInvoker.Invoke(Action executionStep) +85
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +9980113
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +159


Continue reading...
 
Back
Top