我如何使用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)
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
感谢帮助!
.net c# migration entity-framework entity-framework-migrations