I was put on a C# project that already has an SQL database on azure and asked to implement an automatic code first migration system.
We have a db on azure, but I will have to use a localhost test db for this purpose.
In the Web.config there was already a mechanism to choose between azure's or the local db using:
<add name="MS_TableConnectionString" connectionString="..." .. />
I followed the following tutorial step by step but now when I run the application i get the following error:
No service registered for type 'ITableControllerConfigProvider'. Please Ensure That the dependency resolve Has Been Correctly configured.
Error is triggered by WebApiConfig.cs at line 20:
// Use this class to set WebAPI configuration options
HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));
I found this solution online but it didn't work. I added the dependentAssembly for System.Web.Http but still get the same error.
What is the reason behind this error and what is the best approach to handle it?
UPDATE
Thanks to the feedback given, I was able to fix it. For anyone with the same scenario here is what I was missing:
Wrong initializer context and order in Global.asx.cs under Application_Start()
// This must be first in code WebApiConfig.Register(); // Context: get it from Configuration.cs app.Models.MobileServiceContext myDbContext = new app.Models.MobileServiceContext(); // Configuration() should come from your app Database.SetInitializer(new MigrateDatabaseToLatestVersion<app.Models.MobileServiceContext, Configuration>()); myDbContext.Database.Initialize(false);Wrong local connection string:
Since we had a database the connection string was not pointing to the same version number of the one created by migration.
In Web.config<add name="MS_TableConnectionString" connectionString=".....VERSION_NB";.../>Version number must point to the one created by migration.
UPDATE 2
I updated my migration mechanism, inspired by the following tutorial.