![](/img/trans.png)
[英]Having trouble with UseInMemoryDatabase ASP.NET Core 3.1
[英]Create database in UseInMemoryDatabase in ASP.NET Core and identity
我需要在 ASP.NET Core 中創建一個數據庫並使用身份,我需要使用UseInMemoryDatabase
但是當我嘗試添加遷移時,出現此錯誤:
無法創建類型為“DortajContext”的對象。 有關設計時支持的不同模式,請參閱https://go.microsoft.com/fwlink/?linkid=851728
這是我的啟動:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContextPool<DortajContext>(options => options.UseInMemoryDatabase(databaseName: "DortajDistance"));
services.AddIdentity<IdentityUser, IdentityRole>().AddEntityFrameworkStores<DortajContext>();
services.AddControllers();
}
這是我的背景:
public class DortajContext : IdentityDbContext<User, Role, int>
{
public DortajContext(DbContextOptions<DortajContext> options)
: base(options)
{
}
public DbSet<UserDistanceHistory> UserDistanceHistories { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.ApplyConfigurationsFromAssembly(typeof(IType).Assembly);
}
}
我怎么解決這個問題?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.