0

I already have few migrations, and now I am adding another migration, but this time I want to add seed to it. I tried adding this near my Up() and Down() methods:

protected override void Seed(ScykDb context)
{
}

But my compiler says I cannot do that. How can I add seed to my migration?

4

1 回答 1

1

Seed is not available per migration, only at the DbContext level.

You can easily get around it by adding a call to Sql() in your Up() method:

Sql("insert into ponies (col1, col2.....");
于 2013-03-30T16:04:14.613 回答