使用Entity Framework 6的列名无效

时间:2016-09-10 04:06:11

标签: entity-framework

将ASP.NET身份模型与一些自定义表格一起使用,今天我开始获得"无效列名称' AspNetUser_Id'"查询没有与AspNetUser表关联的关系或字段的表PortalActivityRole时。除了我已经读过的溢出线程之外,有没有人有任何建议?

PortalActivityRole

这是" db first"我对PortalActivityrole的映射是:

public class PortalActivityRoleMap : EntityTypeConfiguration<PortalActivityRole>
{
    public PortalActivityRoleMap()
    {
        this.HasKey(t => new { t.ActivityId, t.RoleId });

        // Properties
        this.Property(t => t.ActivityId)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

        this.Property(t => t.RoleId)
            .IsRequired()
            .HasMaxLength(128);

        // Table & Column Mappings
        this.ToTable("PortalActivityRole");
        this.Property(t => t.ActivityId).HasColumnName("ActivityId");
        this.Property(t => t.RoleId).HasColumnName("RoleId");
        this.Property(t => t.DateCreated).HasColumnName("DateCreated");

        // Relationships
        this.HasRequired(t => t.AspNetRole)
            .WithMany(t => t.PortalActivityRoles)
            .HasForeignKey(d => d.RoleId);
        this.HasRequired(t => t.PortalActivity)
            .WithMany(t => t.PortalActivityRoles)
            .HasForeignKey(d => d.ActivityId);

    }
}

PortalActivityRole类是:

public partial class PortalActivityRole
{
    public int ActivityId { get; set; }
    public string RoleId { get; set; }
    public Nullable<System.DateTime> DateCreated { get; set; }
    public virtual AspNetRole AspNetRole { get; set; }
    public virtual PortalActivity PortalActivity { get; set; }
}

0 个答案:

没有答案