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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -