【发布时间】:2017-09-02 06:45:17
【问题描述】:
我如何使用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)
{
}
}
}
感谢您的帮助!
【问题讨论】:
标签: c# .net entity-framework migration entity-framework-migrations