0

私はEF5.xコードファーストを使用しています

namespace DAO.Models
{
    public partial class Person
    {
        public int UserId { get; set; }
}
}

カスタムプロパティを追加するために、別の部分クラスを作成しました。

namespace DAO.Models
{
    public partial class Person
    {
        public string customName { get; set; }
}
}

EF5.xパワーツールによって生成されたマッピングがあります

    public PersonMap()
    {
        // Primary Key
        this.HasKey(t => new { t.PersonId });


        // Table & Column Mappings
        this.ToTable("Person", "TableX");
        this.Property(t => t.PersonId).HasColumnName("PersonId");


    }

新しい人をdbに追加しようとすると

 XContext db = new XContext();

                Person per= new Person();
   db.Persons.Add(per);

フィールドリストエラーで不明な列customNameを取得します

4

1 に答える 1

1

[NotMapped]注釈/属性を使用できます

[NotMapped]
public string customName { get; set; }
于 2013-02-26T23:22:10.313 に答える