Here are my classes
public class Activity
{
public int ID {get;set;}
public string Personnel { get; set; }
public Location Location { get; set; }
}
public class Location
{
[Key]
public string Name { get; set; }
}
When I save an Activity it creates a new Location, even if it already exists. How do I set it up so it uses existing Locations?
Load the existing
Locationthrough the context and use that as the property value of theActivityeg: