EF Migrations - Allow Data Loss on a single migration

ef-migrations entity-framework entity-framework-6

Question

In theConfiguration Entity Framework migrations may include the following line:

AutomaticMigrationDataLossAllowed = true;

This permits data loss while deleting columns, for example.

Is it possible to limit this to certain migrations only?

I don't want this to be set permanently, but if I scaffold a migration that has data loss, I want to have to manually enter that migration and do the following action:

public partial class removing_date_time : DbMigration
{
    public override void Up()
    {
        Configuration.AutomaticMigrationDataLossAllowed = true;
        //...

That seems feasible.

1
3
11/22/2016 1:41:25 PM

Accepted Answer

You five zzz.

Considering that property belongs to the migration automatically. It is incompatible with Code Based Migration, that is, withUp() and Down() This property is owned by theDbMigrationsConfiguration class.

More information may be found at Property AutomaticMigrationDataLossAllowed.

0
11/22/2016 2:29:48 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow