title: How to model "sharing" with Entity Framework code-first - is many-to-many right?
body: <p><code>Users</code> can have one or many <code>Objects</code>.  </p>
  
  <p>An <code>Object</code> can be shared with any number of <code>Users</code>.  </p>
  
  <p>Currently I have: </p>
  
  <pre><code>public class Object
  {
      [Required]
      [Key]
      public virtual int ObjectId { get; set; }
      public List&lt;int&gt; SharedWith { get; set; }
  }
  </code></pre>
  
  <p>But this means that in order to find those Objects that have been shared with a particular User, I have to do something like this: </p>
  
  <pre><code>var objects = new List&lt;Object&gt;();
  foreach (Object object in _context.Objects)
  {
      if (object.SharedWith.Contains(userId){ objects.Add(object) }
  }
  </code></pre>
  
  <p>This seems hardly efficient. What's the right way to model this relationship so the above query can be made more efficient?</p>