properly configure the PatientAtFoodPlace relationship

This commit is contained in:
Andreas Zweili 2018-08-07 22:44:59 +02:00
parent e592b48987
commit afe5d23865
2 changed files with 13 additions and 1 deletions

View File

@ -80,7 +80,7 @@ namespace Server.DB
.HasRequired(e => e.Strain); .HasRequired(e => e.Strain);
modelBuilder.Entity<PatientAtFoodPlace>() modelBuilder.Entity<PatientAtFoodPlace>()
.HasKey(pf => new { pf.PatientID, pf.FoodPlaceID }); .HasKey(pf => pf.PatientAtFoodPlaceID);
modelBuilder.Entity<Person>() modelBuilder.Entity<Person>()
.Property(p => p.FirstName) .Property(p => p.FirstName)
@ -130,6 +130,16 @@ namespace Server.DB
.HasRequired(f => f.City) .HasRequired(f => f.City)
.WithMany() .WithMany()
.WillCascadeOnDelete(false); .WillCascadeOnDelete(false);
modelBuilder.Entity<PatientAtFoodPlace>()
.HasRequired(p => p.Patient)
.WithMany(pf => pf.PatientAtFoodPlaces)
.HasForeignKey(p => p.PatientID);
modelBuilder.Entity<PatientAtFoodPlace>()
.HasRequired(f => f.FoodPlace)
.WithMany(pf => pf.PatientAtFoodPlaces)
.HasForeignKey(f => f.FoodPlaceID);
} }
} }
} }

View File

@ -7,6 +7,8 @@ namespace Server.Models
[DataContract] [DataContract]
public class PatientAtFoodPlace public class PatientAtFoodPlace
{ {
[DataMember]
public int PatientAtFoodPlaceID { get; set; }
[DataMember] [DataMember]
public int PatientID { get; set; } public int PatientID { get; set; }
[DataMember] [DataMember]