1

I am using EF6 with MVC5. I have enabled Migrations and put a Seed method in the Configuration file.

After I deployed to IIS 7, the Seed method keeps running every now and then !! which caused the problem here

My understanding is that it should only run when a migration is done to the DB.

I solved the problem by Publishing again without checking ( Execute Code First Migrations ... )

My question is : why the Seed method was rerunning ?! is it a normal thing ?!

(EDIT)

You were right Yuliam, when I publish and check "Execute Code First Migrations ..." the config file was modified and the following was added:

<contexts>
  <context type="...my context here...">
    <databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[...my context here...], [....Migrations.Configuration, ...]], EntityFramework, PublicKeyToken=some_token">
      <parameters>
        <parameter value="DefaultConnection_DatabasePublish" />
      </parameters>
    </databaseInitializer>
  </context>
</contexts>

So, is this normal ? and should I delete this every time I publish ?

Community
  • 1
  • 1
sami
  • 79
  • 1
  • 6

1 Answers1

2

Thank you again Yuliam, because mentioning "MigrateDatabaseToLatestVersion" pointed me in the right direction.

The short answer is that it was wrong to think that the Seed method only runs with new migrations.

The long answer here and here

Community
  • 1
  • 1
sami
  • 79
  • 1
  • 6