Could not create instance of type: Sitecore.Data.Database. No matching constructor was found.

I have installed, using SIM, sitecore 8.2 and it works as expected.  As soon as I publish my vs2015 mvc project, i receive several assembly reference errors complaining about versions.  Deleting the dlls in the publish dir solves that problem but I am left with this strange error. Could not create instance of type: Sitecore.Data.Database. No matching constructor was found.

I figured it was related to Microsoft DI and AutoFac so I removed AutoFac and configured for MS DI to no avail.  Any suggestions?

  • You may have overwritten the web.config in your Sitecore website folder. If it was included in your Visual Studio solution, it's likely it got deployed and overwrote the web.config that comes with Sitecore out of the box.

    The easiest way to fix this is to simply reinstall your site using SIM and then follow these steps:

    1. in Visual Studio, add .NET assembly references that match Sitecore assembly references exactly (review the .NET assemblies in the Sitecore website\bin folder)
    2. add references to Sitecore DLLs (Sitecore.Kernel, Sitecore.Mvc, etc...) you could use the Sitecore public nuget feed -
    3. replace default Visual Studio web.config with Sitecore web.config located in the root of the Sitecore website folder
    4. remove Global.asax from Visual Studio (the Global.asax in a Sitecore website folder is unique to Sitecore)

    Now, when you deploy from Visual Studio, it should not break your Sitecore site.

  • This error occurs when a connection string name is referenced in a config file but is not present in the ConnectionStrings.config.

    Make sure all the proper connection strings are set up.
  • In reply to Sandy Foley:

    I have this error too. How do I determine which connection string is the issue?

  • In reply to Pravesh Patel:

    Hi, Is the issue resolved? If yes can you please let me know the solution?
  • In reply to Phaneendra Kumar Tolety:

    You shall use resolve="true" to fix this issue
    For Example here cache key is been overridden and need to use the parameterized constructor
    <processor type="Foundation.PipelineExtension.RoleBasedCachingPipeline.CustomGetCacheKey, Foundation.PipelineExtension"
    resolve="true" patch:instead="*[@type='Sitecore.Mvc.Pipelines.Response.RenderRendering.GenerateCacheKey, Sitecore.Mvc']" />