Entity developer (NHibernate) 7.1.151 generating wrong SQL at Update the Database from Model
Hello
If you add an association between two entities with composite primary keys, entity developer (NHibernate) 7.1.151 will generate the wrong sql script at "Update the Database from Model".
Example (Assoc is One Cat to Many Dogs, ISet)
The generated SQL is:
- CREATE TABLE dbo.Cats (
- ID INT NOT NULL,
- Edited DATETIME2 NOT NULL,
- CatFood VARCHAR(8000) NOT NULL,
- CONSTRAINT PK_Cats PRIMARY KEY (ID, Edited)
- )
- GO
- --
- -- Creating a table dbo.Dogs
- --
- CREATE TABLE dbo.Dogs (
- ID INT NOT NULL,
- Edited DATETIME2 NOT NULL,
- DogFood VARCHAR(8000) NOT NULL,
- CatId INT NOT NULL,
- CatEdited DATETIME2 NOT NULL,
- CONSTRAINT PK_Dogs PRIMARY KEY (ID, Edited),
- CONSTRAINT FK_Dogs_Cats_0 FOREIGN KEY (CatId, CatEdited) REFERENCES dbo.Cats (ID, ID)
- )
- GO
Line 19 is obviously wrong ,I think it should be:
- CONSTRAINT FK_Dogs_Cats_0 FOREIGN KEY (DogID, DogEdited) REFERENCES dbo.Cats
nHibernate is generating the correct output at "Schema Export" (and is working...)
- SchemaExport schemaExport = new SchemaExport(conf);
- schemaExport.Create(true, true);