Can I force multiplicity / bindings to Entity Framework?

I have the following table structure that the Entity Framework correctly returns as one-to-many:

Patient
{
   PatientId PK
}

Death
{
   DeathId PK
   PatientId FK
}

Unfortunately, this database project is wrong, since you can only have one Deathfor it Patient. The design should look like this:

Death
{
   PatientId PK
}

However, this is a production system, and the database cannot be changed. I am writing a new ASP.Net MVC interface, so I am rewriting the DAL layer using the Entity Framework.

When I call Patient.Death, I get a collection Death. I want him to return me one or empty Death(since he Patientmight not be dead yet).

, End2 : 0..1 (Zero or One of Death), , :

"" 'RefDeath23. , *.

- , , , ?

+3
2

EF , ? ; EF . , "" SSDL.

, .

EF , , : , , . , , , - , . , () .

+3

EF . , , EF "".

, -.

+1

Source: https://habr.com/ru/post/1757560/


All Articles