protected virtual void ConfigureServiceContainer()
{
this.ServiceContainer.RegisterInstance<IServiceContainer>(this.ServiceContainer);
this.ServiceContainer.RegisterInstance(this.Logger);
this.ServiceContainer.RegisterInstance(this.ModuleCatalog);
if (!this.useDefaultConfiguration)
return;
this.ServiceContainer.Register<IServiceLocator, LightInjectServiceLocatorAdapter>();
this.ServiceContainer.Register<IModuleInitializer, ModuleInitializer>();
this.ServiceContainer.Register<IModuleManager, ModuleManager>();
this.ServiceContainer.Register<RegionAdapterMappings, RegionAdapterMappings>();
// The following 4 registrations are not in the NinjectBootstrapper
this.ServiceContainer.Register<SelectorRegionAdapter, SelectorRegionAdapter>();
this.ServiceContainer.Register<ItemsControlRegionAdapter, ItemsControlRegionAdapter>();
this.ServiceContainer.Register<ContentControlRegionAdapter, ContentControlRegionAdapter>();
this.ServiceContainer.Register<DelayedRegionCreationBehavior, DelayedRegionCreationBehavior>();
this.ServiceContainer.Register<IRegionManager, RegionManager>();
this.ServiceContainer.Register<IEventAggregator, EventAggregator>();
this.ServiceContainer.Register<IRegionViewRegistry, RegionViewRegistry>();
this.ServiceContainer.Register<IRegionBehaviorFactory, RegionBehaviorFactory>();
this.ServiceContainer.Register<IRegionNavigationJournalEntry, RegionNavigationJournalEntry>();
this.ServiceContainer.Register<IRegionNavigationJournal, RegionNavigationJournal>();
this.ServiceContainer.Register<IRegionNavigationService, RegionNavigationService>();
this.ServiceContainer.Register<IRegionNavigationContentLoader, RegionNavigationContentLoader>();
}
我似乎无法获得FOREIGN密钥来处理此声明。我一直收到错误
错误1064(42000):您的SQL语法有错误;检查 手册,对应右边的MySQL服务器版本 要使用的语法&#39; FOREIGN KEY(user_id)REF ERENCES user(id)) AUTO_INCREMENT = 1&#39;在第6行
答案 0 :(得分:0)
在主键后添加逗号:
CREATE TABLE comments (
id INT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
body TEXT DEFAULT NULL,
user_id INT(7) UNSIGNED NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (user_id) REFERENCES user(id)
) AUTO_INCREMENT = 1;
答案 1 :(得分:0)
解决方法是在PRIMARY KEY之后添加一个逗号并将REFERENCES更改为db.table(column)
CREATE TABLE comments (
id INT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
body TEXT DEFAULT NULL,
user_id INT(7) UNSIGNED NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (user_id) REFERENCES blog.users(id)
) AUTO_INCREMENT = 1;