移行パス:dotnet ef --startup-project ../Project.Web migrations add Init
.NETコアEntity Frameworkの - 私は成功したコマンドを使用して.NETコアクラスライブラリを使用して移行ファイルを作成している--output-dirの
私はデシベルコンテキストが異なる層に登録しているので、( Webレイヤー)、そしてクラスライブラリを持っていれば、スタートアッププロジェクトをProject.Webに設定する必要があります。
は私の最初の移行を作成したら、それはこのようなものになります。
をしかし、今、私は、出力-dirのパラメータを使用してみましたがProject.Data/Migrations
Project.Data/Database/Migrations
に私は、移行フォルダを移動したいと思います:
dotnet ef --startup-project ../Project.Web --output-dir Database migrations add Init
しかし、私は得る:
DOTNET:認識されないオプション '--output-dirの'
起動(別のプロジェクトでは、ビジネス層)
public static IServiceCollection InjectBusinessContext(this IServiceCollection services, string connectionString)
{
services.AddEntityFrameworkSqlServer().AddDbContext<ProjectContext>((serviceProvider, options) => options.UseSqlServer(connectionString, b => b.MigrationsAssembly("Database")).UseInternalServiceProvider(serviceProvider));
return services;
}
コンテキスト(データ層)
public class ProjectContext : DbContext
{
public ProjectContext(DbContextOptions<ProjectContext> options) : base(options)
{
}
public DbSet<Account> Account { get; set; }
}
これは..素晴らしいです。乾杯。 – Reft