Hi SeriousM,
It is generally not OK to use DbContext within migrations Up/Down methods because migrations represent your model at a point-in-time whereas your DbContext always represents the latest model. So any migrations that used DbContext could easily become out-of-date and no-longer function correctly (or even compile). Another problem is that we allow you to script migrations using -Script, but any data modifications made "out-of-band" would not be included in a generated script.
The Sql() fluent API is currently the best way to do the data modifications you describe.
Cheers,
Andrew.
It is generally not OK to use DbContext within migrations Up/Down methods because migrations represent your model at a point-in-time whereas your DbContext always represents the latest model. So any migrations that used DbContext could easily become out-of-date and no-longer function correctly (or even compile). Another problem is that we allow you to script migrations using -Script, but any data modifications made "out-of-band" would not be included in a generated script.
The Sql() fluent API is currently the best way to do the data modifications you describe.
Cheers,
Andrew.