If you are using automatic migrations:
You can use [DefaultValue]
attribute when you adding new field.
Or:
You can run update SQL-script:
UPDATE table_name
SET City='SomeDefaultValue'
WHERE City = NULL;
If you are using custom code-based migrations:
When you creating migration for your database, you will got something like:
public override void Up()
{
AddColumn("dbo.someTable", "City", c => c.String(nullable: false, defaultValue: "SomeDefaultValue"));
}
In action parameter you have one of the options: defaultValue
, this value will be used for all existing rows.
May be useful: