c# - EF Code First exception / configuration -
c# - EF Code First exception / configuration -
this first time using code first, please bear me:
i have next entities:
class company { guid id string name virtual list<employee> employees } class employee { guid id string name guid companyid virtual company company }
and next configuration employee:
hasrequired(e => e.company) .withmany(i => i.employees) .hasforeignkey(r => r.companyid) .willcascadeondelete(false);
i can create company list of employees.
however, when seek update company , create eomployees 'null' or empty list next exception:
multiplicity constraint violated. role 'employee_company_target' of relationship 'employee_company' has multiplicity 1 or 0..1.
edit: answers questions in comments:
there nil trying accomplish in particular. wanted test if delete employees related company or ignore it. should either of those, right?
employeeid not foreign key, companyid in employee is.
i've tried updating empty list, didn't work either.
thanks!
c# .net entity-framework ef-code-first code-first
Comments
Post a Comment