visual studio - SQL Server 2005 + Entity Designer -- Foreign Key constraint error? -


using entity designer in vs2010 build database sql server 2005. having problem when try build tables via sql generated "generate database model"; tables created correctly, croaks on foreign key constraints.

the entities @ issue laid out here:

world:   world_id [int32] (primary key)   name [string]  zone:   world_id [int32] (primary key, fk on world.world_id)   zone_id [int32] (primary key)   name [string]  region:   world_id [int32] (primary key, fk on zone.world_id)   zone_id [int32] (primary key, fk on zone.zone_id)   region_id [int32] (primary key)   name [string] 

this part of generated sql code problem:

-- creating foreign key on [zone_id], [world_id] in table 'regions' alter table [dbo].[regions] add constraint [fk_zoneregion]     foreign key ([zone_id], [world_id])     references [dbo].[zones]         ([zone_id], [world_id])     on delete no action on update no action; 

the error this:

there no primary or candidate keys in referenced table 'dbo.zone' match referencing column list in foreign key 'fk_zoneregion'.

i have assume issue has fact that, in multi-column primary key (world_id+zone_id+region_id), both zone_id , world_id foreign keys, , world_id foreign key in table source fk.

is there wrong structure here? not ok me have single association going zone -> region, , in fact have have 2 associations, 1 world -> region , 1 zone -> region?

thanks, -dan

for it's worth, ended re-building entity diagram scratch, , worked. no idea whether had error in initial diagram, or whether glitch entity designer.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -