【发布时间】:2019-05-02 06:09:24
【问题描述】:
我正在尝试在 ASP.NET Core 应用程序中使用 Entity Framework Core Identity
我已经创建了Database Context及其接口,如下:
public class AppDbContext : IdentityDbContext<AppUser>, IAppDbContext
{
public AppDbContext (DbContextOptions<AppDbContext> options) : base(options)
{ }
public DbSet<AppUser> AppUser { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
}
}
public interface IAppDbContext
{
DbSet<AppUser> AppUser { get; set; }
int SaveChanges();
Task<int> SaveChangesAsync();
}
这里的问题是,它在AppDbContext 中显示错误,说明
'AppDbContext' 没有实现接口成员 'IAppDbContext.SaveChangesAsync()'
如果 AppDbContext 继承自 DbContext insted 的 IdentityDbContext 不会出现错误,但要使用 Identity 它应该继承自 IdentityDbContext。
我怎样才能解决这个问题?
【问题讨论】:
标签: c# .net-core asp.net-identity entity-framework-core