将 table 添加到会员数据库

Adding a table to the Membership-database

我正在使用会员数据库进行用户管理。 布局如下所示:

如您所见,我添加了一个新的 table "Downloads"。 在此table我想存储一些额外的信息。

我做了一个class:

public class DownloadInformation
{
    public int Id { get; set;}
    public int UserId { get; set;}
    public string UserName { get; set;}
    public string Filename { get; set;}
    public string UserIpAddress { get; set;}
    public DateTime DownloadDate { get; set; }
}

在我的 ApplicationDbContext 中,我执行了以下操作:

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext()
        : base("DefaultConnection")
    {
    }

    protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
    {

        base.OnModelCreating(modelBuilder);

        var idUser = modelBuilder.Entity<IdentityUser>().ToTable("UserView");
        idUser.Property(p => p.Id).HasColumnName("UserId");
        idUser.Property(p => p.PasswordHash).HasColumnName("Password");
        idUser.Property(p => p.SecurityStamp).HasColumnName("PasswordSalt");
        idUser.Property(p => p.UserName).HasColumnName("UserName");

        var appUser = modelBuilder.Entity<ApplicationUser>().ToTable("UserView");
        appUser.Property(p => p.Id).HasColumnName("UserId");
        appUser.Property(p => p.PasswordHash).HasColumnName("Password");
        appUser.Property(p => p.SecurityStamp).HasColumnName("PasswordSalt");
        appUser.Property(p => p.UserName).HasColumnName("UserName");
        appUser.Property(p => p.Email).HasColumnName("Email");


        var download = modelBuilder.Entity<DownloadInformation>().ToTable("Downloads");
        download.Property(p => p.Id).HasColumnName("Id");
        download.Property(p => p.UserId).HasColumnName("UserId");
        download.Property(p => p.UserIpAddress).HasColumnName("UserIpAddress");
        download.Property(p => p.UserName).HasColumnName("UserName");
        download.Property(p => p.Filename).HasColumnName("Filename");
        download.Property(p => p.DownloadDate).HasColumnName("DownloadDate");
    }
}

但是当我尝试执行以下操作时:

using (ApplicationDbContext app = new ApplicationDbContext())
        {
            DownloadInformation downloadInfo = new DownloadInformation() { UserId = user.UserId, UserName = user.UserName, UserIpAddress = user.IpAddress, Filename = document.FilePath, DownloadDate = DateTime.Now };

            app.Download.Add(downloadInfo);
            app.SaveChanges();
        }

当我编译它时,出现以下错误:

'CustomerPortalDomain.Entities.ApplicationDbContext' 不包含 'Download' 的定义并且没有扩展方法 'Download' 可以找到接受类型 'CustomerPortalDomain.Entities.ApplicationDbContext' 的第一个参数(您是否缺少使用指令或程序集参考?)

我忘记了什么?我错过了什么?

您似乎没有向 ApplicationDbContext

添加任何 'Download' 属性
public DbSet<DownloadInformation> Download{ get; set; }