title: Entity Framework 6 Code first Default value overriding the MigrationCodeGenerator
body: <p>All the approaches I've found about declaring default values, generates the default value in the Sql script, not in the migration code.</p>
  
  <p>My favorite is using attributes: <a href="https://stackoverflow.com/a/34894274/132942">https://stackoverflow.com/a/34894274/132942</a></p>
  
  <pre><code>[SqlDefaultValue(DefaultValue = "getutcdate()")]
  public DateTime CreatedDateUtc { get; set; }
  </code></pre>
  
  <h1>Attribute definition</h1>
  
  <pre><code>[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
  public class SqlDefaultValueAttribute : Attribute
  {
      public string DefaultValue { get; set; }
  }
  </code></pre>
  
  <h1>In the "OnModelCreating" of the context adding</h1>
  
  <pre><code>modelBuilder.Conventions.Add( new AttributeToColumnAnnotationConvention&lt;SqlDefaultValueAttribute, string&gt;("SqlDefaultValue", (p, attributes) =&gt; attributes.Single().DefaultValue));
  </code></pre>
  
  <p>And then customizing the <strong>SqlGenerator</strong>. But I don't like this because I don't see when generating the migration if everything it's as I wanted.</p>
  
  <p>To do so, I modified the <strong>MigrationCodeGenerator</strong> like this: <a href="https://stackoverflow.com/a/21024108">https://stackoverflow.com/a/21024108</a></p>
  
  <h1>In the custom MigrationCodeGenerator</h1>
  
  <pre><code>public class ExtendedMigrationCodeGenerator : MigrationCodeGenerator
  {
      public override ScaffoldedMigration Generate(string migrationId, IEnumerable&lt;MigrationOperation&gt; operations, string sourceModel, string targetModel, string @namespace, string className)
      {
          foreach (MigrationOperation operation in operations)
          {
              if (operation is CreateTableOperation)
              {
                  foreach (var column in ((CreateTableOperation)operation).Columns)
                  {
                      System.Data.Entity.Infrastructure.Annotations.AnnotationValues values;
                      if (column.Annotations.TryGetValue("SqlDefaultValue", out values))
                      {
                          column.DefaultValueSql = (string)values.NewValue;
                      }
                  }
              }
              else if (operation is AddColumnOperation)
              {
                  ColumnModel column = ((AddColumnOperation)operation).Column;
  
                  System.Data.Entity.Infrastructure.Annotations.AnnotationValues values;
                  if (column.Annotations.TryGetValue("SqlDefaultValue", out values))
                  {
                      column.DefaultValueSql = (string)values.NewValue;
                  }
  
              }
          }
  
          CSharpMigrationCodeGenerator generator = new CSharpMigrationCodeGenerator();
  
          return generator.Generate(migrationId, operations, sourceModel, targetModel, @namespace, className);
      }
  }
  </code></pre>
  
  <p>But in the method <strong>ScaffoldedMigration</strong> I cannot get my custom annotation <strong>SqlDefaultValue</strong> or any other annotation.</p>
  
  <p>Is it possible to get this annotation?</p>