title: Entity Framework 5: Using DatabaseGeneratedOption.Computed option
body: <p>I have an EF5 code first project that uses the <code>[DatabaseGenerated(DatabaseGeneratedOption.Computed)]</code> attribute.<br />
  This option is overriding my settings.</p>
  <p>Consider this SQL table:</p>
  <pre><code>CREATE TABLE Vehicle (
    VehicleId  int identity(1,1) not null,
    Name varchar(100) not null default ('Not Set')
  )
  </code></pre>
  <p>I am using the SQL default construct to set the [Name] is case it is not set.</p>
  <p>In code behind, I have a class defined similar to:</p>
  <pre><code>public class Vehicle {
     ...
  
      [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
      public string ShoulderYN { get; set; }
  }
  </code></pre>
  <p>When I update the entity in code, the value set in the default overrides my new setting.</p>
  <p>In code, I have (pseudo):</p>
  <pre><code>vehicle.Name = 'Update Name of Vehicle';
  _dbContext.Update(vehicle);
  _dbContext.SaveChanges();
  </code></pre>
  <p>The expected result is <code>Vehicle.Name = 'Update Name of Vehicle'</code>.<br />
  The actual result is <code>Vehicle.Name = 'Not Set'</code>.</p>
  <p>Is there a way in EF5 to say:<br />
  <em>if Vehicle.Name is null/empty, use the value defined in the database?  Otherwise, if I set the value in code, I want to use this value.</em></p>