0
我正在玩弄ASP.NET 5身份識別並陷入困境。ASP.NET身份框架無法正常工作的實體
這是通過身份樣板背景下創造的:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public DbSet<Transaction> Transactions { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
}
}
我添加了存在身份框架之外的附加實體Transactions
。
當我啓動該網站,所有驗證的東西工作正常,但是當我嘗試查詢Transactions
我得到這個錯誤:
InvalidOperationException: No database providers are configured. Configure a database provider by overriding OnConfiguring in your DbContext class or in the AddDbContext method when setting up services.
進一步尋找這個錯誤,所有的跡象似乎都指向註冊Startup.cs中的服務:
public void ConfigureServices(IServiceCollection services)
{
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
services.AddMvc();
}
儘管如此,仍然出現錯誤。
謝謝!