Все работает хорошо с этим: < /p>
Код: Выделить всё
builder.AddSqlServerDbContext("sqldata");
< /code>
Когда я попробую это: < /p>
builder.Services.AddDbContextPool(options =>
{
var connectionString = builder.Configuration.GetConnectionString("sqldata") ?? throw new InvalidOperationException("Could not read SQL Server connection string");
options.UseSqlServer(connectionString);
options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
});
builder.EnrichSqlServerDbContext();
< /code>
Я получаю ошибку ниже, когда пытаюсь генерировать миграции: < /p>
The exception 'Could not read SQL Server connection string' was thrown while attempting to find 'DbContext' types. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
Подробнее здесь: https://stackoverflow.com/questions/797 ... when-using