Related data not being added for existing parent entity
<p>Im trying to save a rating against a place, I have the code below, but it doesnt seems to save rating (to the ratings table) for an existing entity </p>

<pre><code> place.Ratings.Add(rating);
  _placeRepository.AddPlaceIfItDoesntExist(place);
  _placeRepository.Save();
</code></pre>

<p>This is the repository method</p>

<pre><code> public void AddPlaceIfItDoesntExist(Place place)
        {
            var placeItem = context.Places.FirstOrDefault(x =&gt; x.GooglePlaceId == place.GooglePlaceId);
            if(placeItem==null)
            {
                context.Places.Add(place);
            }
            else
            {
                context.Entry(placeItem).State = EntityState.Modified;
            }
        }
</code></pre>

<p>and this is the poco</p>

<pre><code> public class Place
 {
        public Place()
        {
            Ratings = new List&lt;Rating&gt;();
        }

        public int Id { get; set; }
        public string Name { get; set; }
        public string GooglePlaceId { get; set; }
 }
</code></pre>

<p>I think the crux of the problem is because i need to check if the place exists based on googleplaceid(a string) rather than the id (both are unique per place btw)</p>