SubSonic不会生成MySql外键表 [英] SubSonic isn't generating MySql foreign key tables
问题描述
$ p $
//定义没有外键表(0)
我已经试过了SubSonic 2.1和2.2以及各种MySql 5版本。我必须做程序上的错误 - 任何帮助将不胜感激。使用MS-SQL时,这一直只是开箱即用的。 (
`ParentId` INT(11)NOT NULL AUTO_INCREMENT,
`SomeData
VARCHAR(25)DEFAULT NULL,
PRIMARY KEY(`ParentId`)
)ENGINE = INNODB DEFAULT CHARSET = latin1;
TABLE'child`(
`ChildId` INT(11)NOT NULL AUTO_INCREMENT,
`ParentId` INT(11)NOT NULL,
`SomeData` VARCHAR (25)DEFAULT NULL,
PRIMARY KEY(`ChildId`),
KEY`FK_child`(`ParentId`),
CONSTRAINT`FK_child` FOREIGN KEY(`ParentId`)REFERENCES`parent `(`ParentId`)
)ENGINE = INNODB DEFAULT CHARSET = latin1;
>
< add name =ProviderName
type =SubSonic.MySqlInnoDBDataProvider,SubSonic
connectionStringName =ConnectionString
generateLazyLoads =true
generatedNamespace =My.NameSpace
generateRelatedTablesAsProperties =true
tableBaseClass =ActiveRecord/>
Subsonic 2.2和MySql 5.1.30。
您还应该检查两个表是否是MyISAM。
您是否创建了这个外键?那么Subsonic可能不会注意到你的改变,因为MySQL似乎缓存了Tableschema。请参阅: http://code.google.com/p/subsonicproject/问题/细节?id = 87
I two tables within a MySql 5.1.34 database. When using SubSonic to generate the DAL, the foreign-key relationship doesn't get scripted, ie; I have no Parent.ChildCollection object. Looking inside the generated DAL Parent class shows the following;
//no foreign key tables defined (0)
I have tried SubSonic 2.1 and 2.2, and various MySql 5 versions. I must be doing something wrong procedurally - any help would be greatly appreciated. This has always just worked 'out-the-box' when using MS-SQL.
TABLE `parent` (
`ParentId` INT(11) NOT NULL AUTO_INCREMENT,
`SomeData` VARCHAR(25) DEFAULT NULL,
PRIMARY KEY (`ParentId`)
) ENGINE=INNODB DEFAULT CHARSET=latin1;
TABLE `child` (
`ChildId` INT(11) NOT NULL AUTO_INCREMENT,
`ParentId` INT(11) NOT NULL,
`SomeData` VARCHAR(25) DEFAULT NULL,
PRIMARY KEY (`ChildId`),
KEY `FK_child` (`ParentId`),
CONSTRAINT `FK_child` FOREIGN KEY (`ParentId`) REFERENCES `parent` (`ParentId`)
) ENGINE=INNODB DEFAULT CHARSET=latin1;
It works for me with this settings.
<add name="ProviderName"
type="SubSonic.MySqlInnoDBDataProvider, SubSonic"
connectionStringName="ConnectionString"
generateLazyLoads="true"
generatedNamespace="My.NameSpace"
generateRelatedTablesAsProperties="true"
tableBaseClass="ActiveRecord" />
Subsonic 2.2 and MySql 5.1.30. You should also check if both tables are MyISAM.
And did you just create this foreign key? Then it's likely that Subsonic doesn't notice your changes, because MySQL seems to cache the Tableschema. See: http://code.google.com/p/subsonicproject/issues/detail?id=87
这篇关于SubSonic不会生成MySql外键表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!