Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity Framework Migrations: error on web server only
    text
    copied!<p>error 0175: The specified store provider cannot be found in the configuration, or is not valid</p> <p>I am using Entity Framework Code-First Migrations and everything is great locally.</p> <p>My DB is SQLServer 2008. (Also using SQL CE for local development) I can use the live SQL Server db connection string locally with no problem.</p> <p>Here is the Migration code in _appStart.cshtml:</p> <pre><code>@using EF = System.Data.Entity; @using TCommon = Told.Web.Common.Logic; @{ // Manually initialize var initializer = new EF.MigrateDatabaseToLatestVersion&lt;TCommon.CommonContext, TCommon.Migrations.Configuration&gt;(); System.Data.Entity.Database.SetInitializer(initializer); initializer.InitializeDatabase(new TCommon.CommonContext()); // DB Maintenance TCommon.AppUserLogic.CleanDatabase(); // Asp.Net WebSecurity.InitializeDatabaseConnection("ToldDB", "UserProfile", "UserId", "Email", true); // Common TCommon.AppStart.Run(); } </code></pre> <p>This works great locally. Either against a SQL CE or against my live database. It ran fine locally to migrate my live database to the latest version.</p> <p>However, when I put it on my web server, it throws this exception:</p> <h2>Exception</h2> <pre><code>Server Error in '/' Application. Schema specified is not valid. Errors: (0,0) : error 0175: The specified store provider cannot be found in the configuration, or is not valid. [MetadataException: Schema specified is not valid. Errors: (0,0) : error 0175: The specified store provider cannot be found in the configuration, or is not valid.] System.Data.Metadata.Edm.Loader.ThrowOnNonWarningErrors() +8566285 System.Data.Metadata.Edm.Loader.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths) +181 System.Data.Metadata.Edm.StoreItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError, DbProviderManifest&amp; providerManifest, DbProviderFactory&amp; providerFactory, String&amp; providerManifestToken, Memoizer`2&amp; cachedCTypeFunction) +211 System.Data.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders) +295 System.Data.Entity.Migrations.Extensions.XDocumentExtensions.GetStoreItemCollection(XDocument model, DbProviderInfo&amp; providerInfo) +180 System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, String connectionString) +48 System.Data.Entity.Migrations.DbMigrator.IsModelOutOfDate(XDocument model, DbMigration lastMigration) +55 System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) +269 System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +456 System.Data.Entity.MigrateDatabaseToLatestVersion`2.InitializeDatabase(TContext context) +64 </code></pre> <p>Now, this has something to do with the migration attempt. So when I wrap the migration call in a try-catch block, I can use the database fine (because I migrated the live db locally).</p> <pre><code>@using EF = System.Data.Entity; @using TCommon = Told.Web.Common.Logic; @{ // Manually initialize var initializer = new EF.MigrateDatabaseToLatestVersion&lt;TCommon.CommonContext, TCommon.Migrations.Configuration&gt;(); System.Data.Entity.Database.SetInitializer(initializer); try { initializer.InitializeDatabase(new TCommon.CommonContext()); } catch (Exception ex) { } var db = new TCommon.CommonContext(); var test = db.AppUsers.FirstOrDefault(); // DB Maintenance TCommon.AppUserLogic.CleanDatabase(); // Asp.Net WebSecurity.InitializeDatabaseConnection("ToldDB", "UserProfile", "UserId", "Email", true); // Common TCommon.AppStart.Run(); } </code></pre> <p>What would be causing the migration diff-check to fail when I try to run it on my web server?</p> <hr> <h3>Edit:</h3> <p>Here is the web.config for the Entity Framework:</p> <pre><code>&lt;configuration&gt; &lt;configSections&gt; ... &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/&gt; &lt;/configSections&gt; ... &lt;entityFramework&gt; &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/&gt; &lt;/entityFramework&gt; &lt;system.web&gt; &lt;trace enabled="true" requestLimit="40" localOnly="false" pageOutput="true" /&gt; &lt;customErrors mode="Off"/&gt; &lt;compilation debug="true" targetFramework="4.0"&gt; &lt;assemblies&gt; &lt;add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt; &lt;add assembly="System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt; &lt;/assemblies&gt; &lt;/compilation&gt; &lt;/system.web&gt; ... &lt;connectionStrings&gt; &lt;add name="ToldDB" connectionString="..." providerName="System.Data.SqlClient" /&gt; &lt;/connectionStrings&gt; &lt;/configuration&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload