0
如何使用DbContext
與當前數據庫(現在用於遷移)一起使用。如何在遷移中使用DbContext?
例子:
namespace Data.SqlServer.Migrations
{
[DbContext(typeof(MyDbContext))] // I want use this context
[Migration("CustomMigration_DataSeed")]
public partial class DataSeedMigration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
// add some entities
_context.User.Add(new User());
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
感謝您的幫助!