SubSonic isn't generating MySql foreign key tables

Posted by keith on Stack Overflow See other posts from Stack Overflow or by keith
Published on 2009-06-05T14:34:01Z Indexed on 2010/05/24 23:11 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

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;

© Stack Overflow or respective owner

Related posts about mysql

Related posts about subsonic