0

I have trawled through the web for a day or two for a solution and maybe I'm being stupid but I keep getting the above error when running my project.

Visual Studio 2010, SQL Explress.

I have a group of models with a "one to many" relationship. County->Club->Team->Player

So I can access the "parent / belonging to" models properties in an index list view I have successfully added:

For example, in the club model to access it's parent county properties:

public int CountyId { get; set; }

public virtual County County { get; set; }

This has worked all along the chain until I reach the "player" class. Wanting to list what club the player belongs to (rather than just the ID) I introduce the following ,

public int ClubId { get; set; }

public virtual Club Club { get; set; }  

I get:

Introducing FOREIGN KEY constraint 'Player_Club' on table 'Players' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint. See previous errors.

Why can't I do this?

tereško
  • 58,060
  • 25
  • 98
  • 150
Dubh
  • 55
  • 1
  • 10
  • I think this is a duplicate of this: http://stackoverflow.com/questions/851625/foreign-key-constraint-may-cause-cycles-or-multiple-cascade-paths – Davin Tryon Mar 11 '12 at 00:40
  • Thank you - I seem to have resolved the issue by making the ClubId nullable. – Dubh Mar 11 '12 at 12:16

0 Answers0