已使用 Ninject 和 .Net 4(已测试 4.0 和 4.5)为 Azure 创建了一个 Web 应用程序。在向其添加数据库支持之前,该应用程序已在 Azure 上进行了测试。在本地,它在 SQL Express 上的数据库支持下运行良好。但是在将连接字符串更改为 Azure 并进行部署时,我收到以下错误消息。
我在控制器中没有无参数构造函数,因为我知道 Ninject 需要一个参数化才能工作。
Azure 管理控制台指示与数据库的成功连接。
谁能给我一个提示可能是什么问题?我不得不承认我对 Azure 和 Ninject 都是新手,这是我的培训项目 :-)
[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