c# - Error "cascade delete on" -


i have problem. need add "cascade delete on" in constraint [fk_sumaroute_suma] :

create table [dbo].[sumaroute] (     [id]      int identity (1, 1) not null,     [sumaid]  int not null,     [routeid] int not null,     constraint [pk_sumaroute] primary key clustered ([id] asc),     constraint [fk_sumaroute_suma] foreign key ([sumaid]) references [dbo].[suma] ([id])  ***** here !!! *****,     constraint [fk_sumaroute_route] foreign key ([routeid]) references [dbo].[route] ([id]) on delete cascade ); 

but sql server return errors:

creating fk_part_suma1... (104,1): sql72014: .net sqlclient data provider:
msg 1785, level 16, state 0, line 1
introducing foreign key constraint 'fk_part_suma1' on table 'part' may cause cycles or multiple cascade paths. specify on delete no action or on update no action, or modify other foreign key constraints.
(104,1): sql72014: .net sqlclient data provider:
msg 1750, level 16, state 0, line 1
not create constraint or index. see previous errors.
error occurred while batch being executed.

my tables:

create table [dbo].[suma] (     [id]       int           identity (1, 1) not null,     [sumaname] nvarchar (50) not null,     constraint [pk_suma_1] primary key clustered ([id] asc) ); create table [dbo].[route] (     [id]        int           identity (1, 1) not null,     [routename] nvarchar (50) not null,     constraint [pk_route] primary key clustered ([id] asc) ); 

edit: next tables

create table [dbo].[part] (     [id]       int           identity (1, 1) not null,     [partname] nvarchar (50) not null,     [sumaid]   int           not null,     [place]    nvarchar (50) null,     [time]     time (7)      null,     constraint [pk_part] primary key clustered ([id] asc),     constraint [fk_part_suma1] foreign key ([sumaid]) references [dbo].[suma] ([id]) ); create table [dbo].[order] (     [id]             int      identity (1, 1) not null,     [partid]         int      not null,     [routeid]        int      null,     [sumaid]         int      not null,     [driverid]       int      null,     [express]        bit      constraint [df_order_express] default ((0)) not null,     [status]         int      constraint [df_order_status] default ((0)) not null,     [timeleft]       datetime not null,     [starttransport] datetime null,     [created]        datetime null,     constraint [pk_order] primary key clustered ([id] asc),     constraint [fk_order_part] foreign key ([partid]) references [dbo].[part] ([id]) on delete cascade,     constraint [fk_order_route] foreign key ([routeid]) references [dbo].[route] ([id]) on delete cascade,     constraint [fk_order_suma] foreign key ([sumaid]) references [dbo].[suma] ([id]) on delete cascade,     constraint [fk_order_user] foreign key ([driverid]) references [dbo].[user] ([id]) on delete cascade ); create table [dbo].[user] (     [id]            int            identity (1, 1) not null,     [pin]           nchar (4)      not null,     [sumaidsigned]  int            null,     [routeidsigned] int            null,     [name]          nvarchar (50)  not null,     [surname]       nvarchar (50)  not null,     [type]          bit            not null,     [tokengcm]      nvarchar (400) null,     [tokenaccess]   nvarchar (50)  null,     [signedtime]    datetime       null,     constraint [pk_user] primary key clustered ([id] asc),     constraint [fk_user_route] foreign key ([routeidsigned]) references [dbo].[route] ([id]),     constraint [fk_user_suma] foreign key ([sumaidsigned]) references [dbo].[suma] ([id]) ); 

i can remove suma, route , user. if remove suma row (id = 5) , order contain sumaid(5) need remove orders sumaid(5).

what have doing pls? sorry english :)


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -