title: How can i hide "setters" from all but one assembly?
body: <p>I have alluded to this issue in <a href="https://stackoverflow.com/questions/3878112/advice-on-poco-validation-with-asp-net-mvc-entity-framework">my other question</a>, but i think it's worthwhile breaking it out into its own question, as it's not really dependant on the other scenarios i mentioned.</p>
  
  <p>Anyways - onto the Q, don't know if this is possible. Looking for a solution/workaround.</p>
  
  <p>I have a Class Library, with nothing but POCO's:</p>
  
  <pre><code>MyCompany.MyProject.Domain.POCO
  </code></pre>
  
  <p>This assembly has a POCO like this:</p>
  
  <pre><code>public class Post
  {
     public int PostId { get; set; }
     public int Name { get; set; }
        ...
  }
  </code></pre>
  
  <p>Now, i have another Class Library, which is my DAL/Repository, and uses Entity Framework 4.0 for the persistence:</p>
  
  <pre><code>MyCompany.MyProject.Repositories
  </code></pre>
  
  <p>This assembly has a reference to the POCO project, as it needs to be perform CRUD operations on the POCO's (grab DB objects, project into POCO's, return, as well as modify POCO's).</p>
  
  <p>Now, i also have a <strong>Web Application</strong>, which has a reference to both the POCO and Repository assembly.</p>
  
  <p>If i do this:</p>
  
  <pre><code>somePOCO.PostId = 10;
  </code></pre>
  
  <p>I get a SQLException, as <strong>PostId</strong> is an IDENTITY field in the database, and hence should not be explicity set.</p>
  
  <p>Is there a way i can <strong>hide</strong> the setter for these special properties, so that only the repository has access to the setter?</p>
  
  <p>I can't think of a way to do it with regular accessibility modifiers (as none of them suit the scenario), can you guys think of a workaround?</p>