The only way I know this is through "normal" migration. In EF6, I add a migration (in the example below it is called "V1"), which results in a new migration with empty methods Up () and Down (). You can then add custom SQL commands to these methods before starting the update database to place them in a βnormalβ migration stream.
You can modify the existing migration to add these features, but I prefer that my automatic forests be separated from my custom ones.
public partial class V1 : DbMigration { public override void Up() { Sql("CREATE SPATIAL INDEX [IX_UserProfileAddresses_Location] ON [dbo].[UserProfileAddresses](Location)"); } public override void Down() { Sql("DROP INDEX [IX_UserProfileAddresses_Location] ON [dbo].[UserProfileAddresses]"); } }
Not an ideal method, but not so bad as it executes the βnormalβ migration pattern for EF.
source share