title: .Net Core - How to add SQL Column Constraint using EF Core
body: <p>In a .net core 3.1 web application, what file am I suppose to edit to add a DEFAULT constraint to a table that is being created by EF?</p>
  
  <p>Right now I have a migrations folder with a InitialCreate, RenamedTable, and TableDefault migration.  Before creating the TableDefault migration, I went into the DbContextModelSnapshot.cs file and added this to one of the columns</p>
  
  <pre><code>b.Property&lt;string&gt;("EmergencyChange")
                          .IsRequired()
                          .HasColumnType("nvarchar(max)")
                          .HasDefaultValue("False"); //Default constraint I added
  </code></pre>
  
  <p>I then created a new migration and gave it the name TableDefault.  However, when I go to update-database, I notice the down method is actually applying those constraints and not the UP method?</p>
  
  <pre><code>public partial class TableDefaults : Migration
      {
          protected override void Up(MigrationBuilder migrationBuilder)
          {
              migrationBuilder.AlterColumn&lt;string&gt;(
                  name: "Submitter",
                  table: "tblChanges",
                  nullable: false,
                  oldClrType: typeof(string),
                  oldType: "nvarchar(max)",
                  oldDefaultValueSql: "SUSER_Name()");
  
              migrationBuilder.AlterColumn&lt;string&gt;(
                  name: "EmergencyChange",
                  table: "tblChanges",
                  nullable: false,
                  oldClrType: typeof(string),
                  oldType: "nvarchar(max)",
                  oldDefaultValue: "False");
          }
  
          protected override void Down(MigrationBuilder migrationBuilder)
          {
              migrationBuilder.AlterColumn&lt;string&gt;(
                  name: "Submitter",
                  table: "tblChanges",
                  type: "nvarchar(max)",
                  nullable: false,
                  defaultValueSql: "SUSER_Name()",
                  oldClrType: typeof(string));
  
              migrationBuilder.AlterColumn&lt;string&gt;(
                  name: "EmergencyChange",
                  table: "tblChanges",
                  type: "nvarchar(max)",
                  nullable: false,
                  defaultValue: "False",
                  oldClrType: typeof(string));
          }
      }
  </code></pre>
  
  <p>So when I run the UP method, it basically does nothing, but if I revert back to the 2nd migration, it runs the down method and now all of a sudden the constraint is applied.  So, what am I doing wrong?  I could just swap the UP/DOWN method, but I am pretty certain I am doing something fundamentally incorrect.</p>