title: Do EntityFramework collection properties need a setter
body: <p>The usual approach for modeling 1-n relations with EntityFramwork (Code First) is to use virtual collection properties like:</p>
  
  <pre><code>class Project {
    public virtual ICollection&lt;Remark&gt; Remarks { get; set; }
  }
  
  class Remark {
    public virtual int ProjectId { get; set; }
    public virtual Project Project {get; set; }
  }
  </code></pre>
  
  <p>Since the <code>Remarks</code> collection is initially <code>null</code>, I take the following approach</p>
  
  <pre><code>  private ICollection&lt;Remark&gt; _remarks;
    public virtual ICollection&lt;Remark&gt; {
      get {
        if (_remarks == null)
          _remarks = new List&lt;Remark&gt;();
        return _remark;
      }
      set {
         _remarks = value;
      }
    }
  </code></pre>
  
  <p>in order to use the <code>Remarks.Add</code> method on a newly created <code>Project</code> object without the need to explicitely set the Property.</p>
  
  <p>Afaik EF internally derives from my class and overwrites the virtual navigation properties to support lazy loading.</p>
  
  <p>My question: Do I need to define the <em>setter</em> of a collection property? Does EF require it? I'd rather like to only expose the getter and let the class manage the collection internally.</p>
  
  <p><em>Edit</em> Accidentially I only noticed this <a href="https://stackoverflow.com/questions/11191103/entity-framework-read-only-collections">related question</a> just after postin mine, so maybe it's just a duplicate ...</p>