Have created a web application with Ninject and .Net 4 (have tested both 4.0 and 4.5) intended for Azure. The application has been tested ok on Azure before adding database support to it. Locally it runs ok with database support on SQL Express. But when altering the connect string to the Azure one and deployes it, I get the following error message.
I do NOT have a parameterless constructor in the controller, as I understand that Ninject needs one which is parameterized to work.
Azure administrative console indicates successfull connections to database.
Can anyone give me a hint for what might be wrong? I have to admit that I am new to both Azure and Ninject, this is my training project 🙂
[NotSupportedException: Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations.]
System.Data.Entity.Internal.ModelCompatibilityChecker.CompatibleWithModel(InternalContext internalContext, ModelHashCalculator modelHashCalculator, Boolean throwIfNoMetadata) +221
System.Data.Entity.DropCreateDatabaseIfModelChanges`1.InitializeDatabase(TContext context) +218
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +66
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +225
System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +208
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +235
System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes() +65
System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext() +36
STT.data.Repository.UnitOfWork..ctor(IDatabaseFactory databaseFactory) +88
DynamicInjector34635b924a6c4e6ab03c67010341a739(Object[] ) +92
Ninject.Activation.Context.Resolve() +294
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +248
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +300
System.Linq.WhereSelectArrayIterator`2.MoveNext() +82
System.Linq.Buffer`1..ctor(IEnumerable`1 source) +520
System.Linq.Enumerable.ToArray(IEnumerable`1 source) +103
Ninject.Activation.Providers.StandardProvider.Create(IContext context) +480
Ninject.Activation.Context.Resolve() +294
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +248
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +300
System.Linq.WhereSelectArrayIterator`2.MoveNext() +82
System.Linq.Buffer`1..ctor(IEnumerable`1 source) +520
System.Linq.Enumerable.ToArray(IEnumerable`1 source) +103
Ninject.Activation.Providers.StandardProvider.Create(IContext context) +480
Ninject.Activation.Context.Resolve() +294
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +248
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +300
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +78
[InvalidOperationException: An error occurred when trying to create a controller of type 'STT.web.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +256
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +81
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +270
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +86
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12551795
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Looks like an issue with EF.
NotSupportedException: Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations.EF 4 Code First: Model compatibility cannot be checked because the EdmMetadata type was not included in the model