I use VS2012 and the Entity constructor to create both a database and models. I have a very simple script, Table1 to Table1and2JoinTable for Table2. Something like students, classes, StudentClasses. You can have many students in many classes. I would like to have cascading deletion. Therefore, if you delete a student, any rows in the StudentClass join table are deleted for this student ID. The same goes for class deletion; any rows in StudentClass are deleted for this class identifier. After you created the association "many to many" in the designer and set the parameters for removing the cascade, you get the following error when trying to create a database:
Error 132: End 'Student' in relation to 'Model1.StudentClass' cannot have the specified operation because its multiplicity is equal to ''. Operations cannot be specified at the ends with a multiplicity. ''
Here is a small example:

Here is the association created:

And the error messages received:

Here is the part of the SQL code for generating database tables:
-- Creating foreign key on [Students_Id] in table 'StudentClass' ALTER TABLE [dbo].[StudentClass] ADD CONSTRAINT [FK_StudentClass_Student] FOREIGN KEY ([Students_Id]) REFERENCES [dbo].[Students] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION; -- This should be ON DELETE CASCADE ON UPDATE NO ACTION; GO -- Creating foreign key on [Classes_Id] in table 'StudentClass' ALTER TABLE [dbo].[StudentClass] ADD CONSTRAINT [FK_StudentClass_Class] FOREIGN KEY ([Classes_Id]) REFERENCES [dbo].[Classes] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION; -- This should be ON DELETE CASCADE ON UPDATE NO ACTION; GO
I know how to get around this by simply editing the script database and adding the on delete cascade option. But I do not want to do this, because I am going to return to the designer many times when the project is growing, and I do not want to remember this step every time.
Has anyone figured out how to solve this?
source share