0

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
}

また、db コンテキストも確認しましたが、そこにもあり、完全にマッピングされています。

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 を使用しています。

助けてくれてありがとう。

4

2 に答える 2

6

エンティティ データ モデルでサポートされるプリミティブ データ型

したがって、 a のstring代わりに aを使用する必要があるcharと思います

いくつかのデータを追加しますOnModelCreating

modelBuilder.Entity<MasterUser>()
            .Property(usr => usr.Rank).HasColumnName("MUSR_RANK")
            .HasMaxLength(1)
            .IsFixedLength()
            .IsUnicode(false);
于 2012-11-02T11:24:09.270 に答える