MvcSiteMapProvider 2.3.1 startup error

Apr 4, 2011 at 3:54 PM

I downloaded the MvcSiteMapProvider 2.3.1 and ran the MvcSiteMapProvider.sln on VS 2010. Upon starting the project for the first time I received this error:

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid

I replaced MvcSiteMapProvider.dll, version 2.3.1 with version 3.0.0, and replaced System.Web.Mvc, version 2 with version 3.  I tailored the MusicStoreEntities connection string for my database.  But I still see the same error.  The source error:

Line 41:         /// Initializes a new MusicStoreEntities object using the connection string found in the 'MusicStoreEntities' section of the application configuration file.
Line 42:         /// </summary>
Line 43:         public MusicStoreEntities() : base("name=MusicStoreEntities", "MusicStoreEntities")
Line 44:         {
Line 45:             this.ContextOptions.LazyLoadingEnabled = true;

The stack:

[ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.]
   System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +8080056
   System.Data.EntityClient.EntityConnection..ctor(String connectionString) +81
   System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString) +42
   System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName) +16
   MvcMusicStore.Models.MusicStoreEntities..ctor() in C:\Users\djones.CENTRIC\Documents\Visual Studio 2010\Projects\MvcSiteMapProvider_2.3.1_Sample_Application\MvcMusicStore\Models\StoreDB.Designer.cs:43
   MvcMusicStore.Controllers.HomeController..ctor() in C:\Users\djones.CENTRIC\Documents\Visual Studio 2010\Projects\MvcSiteMapProvider_2.3.1_Sample_Application\MvcMusicStore\Controllers\HomeController.cs:14

[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) +98
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +67

[InvalidOperationException: An error occurred when trying to create a controller of type 'MvcMusicStore.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +182
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +80
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +196
   System.Web.Mvc.<>c__DisplayClass6.<BeginProcessRequest>b__2() +49
   System.Web.Mvc.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a() +13
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +124
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +98
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841400
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

 

Does anyone know the cure?

 

Coordinator
Apr 5, 2011 at 6:11 AM

The database tries to connect to .\SQLEXPRESS. CHange the connection string to reflect your local SQLEXPRESS insallation.