我收到了错误The property 'Rank' is not a declared property on type 'MasterUser'. Verify that the property has not been explicitly excluded from the model by using the Ignore method or NotMappedAttribute data annotation. Make sure that it is a valid primitive property.
,我检查了我的模型类,它就在那里。
public class MasterUser
{
//many other properties...
public virtual char Rank { get; set; }
//more properties below
}
我还检查了我的数据库上下文,它也在那里并且完美映射。
public class BBDataContext : DbContext
{
public DbSet<MasterUser> Users { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
#region MUSR_USRID mapping
//Mapped properties above....
modelBuilder.Entity<MasterUser>()
.Property(usr => usr.Rank).HasColumnName("MUSR_RANK");
//More mapped properties..
modelBuilder.Entity<MasterUser>().ToTable("dbo.MUSR_FIL");
#endregion
base.OnModelCreating(modelBuilder);
}
}
在表中,MUSR_RANK
可使用 char 数据类型为空。
我怎样才能解决这个问题?数据库对此有影响吗?我目前正在使用 SQL Server 2000。
谢谢您的帮助。