entity framework - SQLException: Multiple Cascade Paths? -
i have next model:
public class job { [key] public int jobid { get; set; } public string description { get; set; } public datetime datecreated { get; set; } public datetime? duedate { get; set; } public int jobidentity { get; set; } [maxlength(50, errormessage = "please ensure job title less 50 characters")] public string jobtitle { get; set; } public int priority { get; set; } // relationships [foreignkey("category")] public int categoryid { get; set; } [foreignkey("jobtype")] public int jobtypeid { get; set; } [foreignkey("userrequestedby")] public int requestedby { get; set; } [foreignkey("usercreatedby")] public int createdby { get; set; } // navigation properties public virtual jobtype jobtype { get; set; } public virtual category category { get; set; } public virtual user userrequestedby { get; set; } public virtual user usercreatedby { get; set; } public virtual icollection<task> tasks { get; set; } public virtual icollection<jobnote> notes { get; set; } }
but when seek run application next error:
introducing foreign key constraint 'fk_dbo.jobs_dbo.users_createdby' on table 'jobs' may cause cycles or multiple cascade paths. specify on delete no action or on update no action, or modify other foreign key constraints. not create constraint. see previous errors.
with cascade delete on default, deleting user has 2 cascade paths - requestedby , createdby
disabling cascade deletion exhibited in this question.
entity-framework
No comments:
Post a Comment