title: Posting entity class when only some fields are provided by user
body: <p>I'm curious how people are handling this.</p>
  
  <p>I've used Visual Studio to add CRUD pages with Entity Framework to my Razor Pages application.</p>
  
  <p>But, as is, there's no way the <em>Create</em> page is going to validate. That's because the entity has fields such as a user ID, a creation date with default value, and a couple of fields that I want to set default values. So <code>ModelState.IsValid</code> is obviously going to return <code>false</code>. And it seems like it would rarely be the case that the user will provide exactly the right data for every field of an entity.</p>
  
  <p>One option for dealing with this is to create a new class that has only the fields I need from the user, and then copy them over to the entity before saving it to the database.</p>
  
  <p>The other option is to write code that populates the fields that don't rely on user input before calling <code>ModelState.IsValid</code>.</p>
  
  <p>This is a new situation for me. I would love to hear how some other people handle this situation.</p>