Make sure the provider is registered in the 'entityFramework' section of the application config file - entity-framework-6

I have installed Entity Framework 6.2.0 and working with a code-first approach while creating database and fetch any data getting this error:
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file
I have attached the web.config and app.config.
Web.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0"/>
<add key="webpages:Enabled" value="false"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6"/>
<httpRuntime targetFramework="4.6"/>
</system.web>
<connectionStrings>
<add name="GetMeShopContext"
connectionString="Data Source=localhost;Initial Catalog=GetMeShop;Integrated Security=true"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
<remove name="OPTIONSVerbHandler"/>
<remove name="TRACEVerbHandler"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
App.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>

You're saying you have a web.config and an app.config which leads me to believe you probably have a web application, and the Entity Framework code is stored in a class library that this web application references.
This will work just fine - BUT the config from the class library (in the app.config) will not be read and used - you need to physically copy & paste that config (the <configSections> and <entityFramework> sections) from your class library's app.config, and insert those two sections into the web application's web.config so that it will have any effect at all.
This is a basic design decision of the .NET configuration system and holds true for all .NET application - only the main (host) application's config file is read and used - references class library's app.config files are not interpreted and used.

Related

Sitecore helix Apply-Xml-Transform replaces entire web.config instead of transforming

Experiencing an issue whereby when my Gulp task runs the XMLTransform task, it's replacing the entire contents of Sitecore application web.config file instead of transforming elements.. Can't see why?
I have 2x web.config.transform files in different projects in my solution, both of which have the XML-Document-Transform namespace that have very little in them so far.. example of one is here:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<runtime xdt:Transform="InsertIfMissing">
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" xdt:Transform="InsertIfMissing">
<dependentAssembly xdt:Transform="InsertIfMissing">
<assemblyIdentity xdt:Transform="InsertIfMissing" name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect xdt:Transform="InsertIfMissing" oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly xdt:Transform="InsertIfMissing">
<assemblyIdentity xdt:Transform="InsertIfMissing" name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect xdt:Transform="InsertIfMissing" oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly xdt:Transform="InsertIfMissing">
<assemblyIdentity xdt:Transform="InsertIfMissing" name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect xdt:Transform="InsertIfMissing" oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
</dependentAssembly>
<dependentAssembly xdt:Transform="InsertIfMissing">
<assemblyIdentity xdt:Transform="InsertIfMissing" name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect xdt:Transform="InsertIfMissing" oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom xdt:Transform="InsertIfMissing">
<compilers xdt:Transform="InsertIfMissing">
<compiler xdt:Transform="InsertIfMissing" xdt:Locator="Match(language)" language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler xdt:Transform="InsertIfMissing" xdt:Locator="Match(language)" language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
</configuration>
My gulpfile is pretty much the stock standard Helix one:
gulp.task("04-Apply-Xml-Transform", function () {
var layerPathFilters = ["./src/Foundation/**/*.transform", "./src/Feature/**/*.transform", "./src/Project/**/*.transform", "!./src/**/obj/**/*.transform", "!./src/**/bin/**/*.transform"];
return gulp.src(layerPathFilters)
.pipe(foreach(function (stream, file) {
var fileToTransform = file.path.replace(/.+code\\(.+)\.transform/, "$1");
util.log("Applying configuration transform: " + file.path);
return gulp.src("./scripts/applytransform.targets")
.pipe(msbuild({
targets: ["ApplyTransform"],
configuration: config.buildConfiguration,
logCommand: false,
verbosity: "normal",
stdout: true,
errorOnFail: true,
maxcpucount: 0,
toolsVersion: config.buildToolsVersion,
properties: {
Platform: config.buildPlatform,
WebConfigToTransform: config.websiteRoot,
TransformFile: file.path,
FileToTransform: fileToTransform
}
}));
}));
});
applytransform.targets file is also the stock helix one:
<Project ToolsVersion="14.0" DefaultTargets="ApplyTransform" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(MSBuildToolsVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="ApplyTransform">
<ItemGroup>
<Transform Include="$(TransformFile)" />
<ConfigsToTransform Include="$(FileToTransform)" Condition="Exists(#(Transform))">
<TransformPath>%(Transform.Identity)</TransformPath>
</ConfigsToTransform>
</ItemGroup>
<Message Text="#(ConfigsToTransform)"></Message>
<Message Text="#(Transform)"></Message>
<TransformXml Source="$(WebConfigToTransform)\%(ConfigsToTransform.Identity)"
Transform="%(ConfigsToTransform.TransformPath)"
Destination="$(WebConfigToTransform)\%(ConfigsToTransform.Identity)"
Condition="Exists(#(Transform))"/>
</Target>
</Project>
When I run the task the output all looks normal, however the resultant web.config file in my website root contains ONLY what is in the two transform files and I lose all the regular application configuration settings..
Anyone know what's up?
Turns out my issues were two-fold.
I didn't look closely enough at the Sitecore.Foundation.Installer Project which I thought was being used only for Installing dummy XDB and Reporting data but in actual fact contains some of the logic for the transformation tooling in it.
I had added some new projects to foundation/feature layers and it turns out that by default a web.config file when you right-click -> View Properties has it's "Build Action' set to "content" which results in this file being put in the output directory that is ultimately published to the web root directory. This should be set to 'None' and 'Copy to Output Directory' set to "Do not copy'.

VS2015 - IntelliSense not working in razor views in a class library

I am having a hard time describing the exact issue, but is appears to be "just" an IntelliSense problem that only shows in razor (.cshtml) views. Been looking at this for 2 days now so I could really use some help.
I am using VS2015 Pro, started a new Web MVC application (WebApplication2 ) using the standard template. Inside that application everything works just fine.
Now I have added a class library project (the default one, not the "Package" template), and added the WebPages, MVC and razor nuget packages to it (in case that is relevant). The problem becomes visible as soon as I create a new view in the class library. It appears that all references to System libraries are unavailable in the cshtml file.
With no files opened I get no errors at all, but when I open the view all system classes have the red squiggly line under them, and the Error list (Build + IntelliSense) suddenly contains a lot of errors for every system* library, example:
The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
These include Linq, and the WebApplication2 (the test project), so not just System.Web.
Things that I have checked and done bases on similar answers on stack:
The web.config in the Views folder contains the correct versions, also tried just copying the one from the web application.
Reinstalled the nuget packages (Mvc, Razor, Webpages).
Resetting the userdata and removing the .vs folder.
Copy local is set to true on assemblies.
The actual case where we discovered this is our larger web application which was working fine in VS2010, but then we decided to upgrade to 2015 and .Net 4.6. The views in the class library are marked as embedded resource and loaded using a virtual path provider. The case above is a super simplified reproducible project, the symptoms are the same on my and my 2 colleagues' computers.
If I missed a crucial bit of information, please just ask.
Image visualizing the issue
A reply in the article Stephen Muecke commented with got me started in the right direction. The solution is a mix of probably my confusion of which config needs to be where, and what feels like a workaround to something...
Set the [Output Path] of your class library project to [bin/]. Mohammad Chehab mentions this in his (currently offline?) blog post which was referenced in this article: http://thetoeb.de/2014/01/05/enabling-mvc5-intellisense-in-a-classlibrary-project/
In your [ClassLibrary/Views] folder you should have a Web.config which includes the correct razor versions and namespaces. I just copied the contents of the Web.config from our working Web application project and added/changed some namespaces. Example below.
In your [ClassLibrary] root folder you should change the App.config so that it also contains the system.web section with the compilation setting. Example below.
After changing these to a clean, close the solution, delete the bin folders, open the solution and for me it finally all worked again.
I do have a sporadic issue with System.Web.Mvc.xml being locked, perhaps a side effect of the output path change that MS did not foresee or something... Perhaps nothing to worry about.
Hope this helps some poor googling soul some day.
Project/Views/Web.config
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
<system.web>
<compilation>
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
</configuration>
Project/App.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.6" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Microsoft.Data.OData Version mismatch for Breeze Server - for Web API 2

Breeze Server - for Web API 2 version 1.4.8 in Nuget installs Microsoft.Data.OData Version=5.6.1, yet references version 5.6.0.
See error below:
Metadata query failed for: *; Could not load file or assembly 'Microsoft.Data.OData, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Make sure you correct the correct assembly versioning (web.config if a web project) as:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.1.0" />
</dependentAssembly>
</assemblyBinding>
Then in your Data project's app.config file, comment out the <entityFramework> section:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
Then, if you don't already have it, add the following config section:
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
Lastly, in your XxDbContext class, add/modify your static constructor as:
static XxDbContext()
{
var type1 = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
}
These steps fixed my issue.
Good luck.
[Symptom]
If you started having this issue without introducing new dependencies, it is likely that your temporary asp.net folder has lost integrity.
[Solution]
Try deleting %LOCALAPPDATA%\Temp\Temporary ASP.NET Files\

issue deploying asp.net mvc 5 to iis server

I am trying to publish / deploy my site to a iis 7 server.
When I click run in visual studio it works perfectly.
I followed a tutorial to use the web deploy to my server. the files are there and everything seems ok.
but when I go to the site: http://10.0.0.12:8000/
I get: HTTP Error 403.14 - Forbidden, The Web server is configured to not list the contents of this directory.
I have given the site administrator credentials. And I checked there are default pages configured.
What am I doing wrong?
Here is my config File:
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
Things to try and check:
Set the runAllManagedModulesForAllRequests="true"attribute on the <modules> section in your web.config:
<modules runAllManagedModulesForAllRequests="true">
The website is configured to use an Application Pool using ASP.NET 4.0, Integrated Pipeline mode
ASP.NET 4.0 is registered in IIS. Use the following command to ensure this is the case (might need to adjust the Framework64 folder with Framework if you are on a 32 bit server):
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -ir
Go to the web.config at the wed sites physical deployed locationand open it
And you will find a an xml tag, almost at the end of the xml file, as the following content
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
....
</handlers>
<!--ENTER THE CODE HERE-->
</system.webServer>
At the given location add the following code piece save and refresh ur site
<modules runAllManagedModulesForAllRequests="true">
Also Try removing any othere tags already available!

Failed to find or load the registered .Net Framework Data Provider. - ASP.NET MVC 4 + Entity Framework

I getting error on server while running "Failed to find or load the registered .Net Framework Data Provider.". I have Sql Compact 4 database included to ASP.NET MVC 4 + Entity Framework, uploading on godaddy server... web.config is following
Web.Config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="EShip" connectionString="Data Source=|DataDirectory|\EShip.sdf" providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off"/>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0"/>
<add name="Microsoft SQL Server Compact Data Provider 4.0"
invariant="System.Data.SqlServerCe.4.0"
description=".NET Framework Data Provider for Microsoft SQL Server Compact"
type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1,
Culture=neutral,
PublicKeyToken=89845dcd8080cc91"/>
</DbProviderFactories>
</system.data>
</configuration>
[/xml]
Using the comment of the OP, I have a slightly more verbose version.
With nuget in hand, one can run the command
install EntityFramework.SqlServerCompact
to download SqlServerCompact When I try that, I see 3 dependencies come along with that so you get 4 installs in total:
Microsoft.SqlServer.Compact
SqlServerCompact
EntityFramework
EntityFramework.SqlServerCompacy
It can therefore be inferred that a likely cause of running into this problem is missing SqlServerCompact for your installation.
I had a similar problem with a simple test app.
Install-Package EntityFramework.SqlServerCompact got rid of the message 'Failed to find or load the registered .Net Framework Data Provider' by adding SqlServer Compact dlls to the app 'packages' directory. It added the following to the packages.config;
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="5.0.0" targetFramework="net40-Client" />
<package id="EntityFramework.SqlServerCompact" version="4.3.6" targetFramework="net40-Client" />
<package id="Microsoft.SqlServer.Compact" version="4.0.8876.1" targetFramework="net40-Client" />
<package id="SqlServerCompact" version="4.0.8854.1" targetFramework="net40-Client" />
</packages>
It also added System.Data.SqlServerCe and System.DataSqlServerCe.Entity to the app references.
I then got an exception like this;
System.IO.FileLoadException was unhandled
Message=Could not load file or assembly 'System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=mscorlib
FileName=System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91
FusionLog==== Pre-bind state information ===
LOG: User = mulcahy\mulcahy_admin
LOG: DisplayName = System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91
(Fully-specified)
LOG: Appbase = file:///C:/Users/mulcahy_admin/Dropbox/projects/ons/CSLCE4CL/CSLCE4CL/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\mulcahy_admin\Dropbox\projects\ons\CSLCE4CL\CSLCE4CL\bin\Debug\CSLCE4CL.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.0.1 redirected to 4.0.0.1.
LOG: Post-policy reference: System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91
LOG: Attempting download of new URL file:///C:/Users/mulcahy_admin/Dropbox/projects/ons/CSLCE4CL/CSLCE4CL/bin/Debug/System.Data.SqlServerCe.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
This seems to suggest that the app is configured to use SqlServerCE v4.0.0.1 - but finds v4.0.0.0
So i used Eriks suggestion and changed the DbProviderFactories entry to say v4.0.0.0 and removed the bindingRedirect entry that refered to a new version at v4.0.0.1.
This seems to work. Hope it helps anyone following this path...
Meanwhile I'm a bit puzzled;
Why is the System.Data.SqlServerCe.dll at version 4.0.8876.1 - how could I know that this is actually v4.0.0.0
Where did the v4.0.0.1 reference come from - I must have this version somewhere on my machine?

Resources