2012-03-17 6 views
1

が、私はエラーを取得しています有効ではありません - A specified Include path is not valid. The EntityType 'myProject.DAL.Paint' does not declare a navigation property with the name 'Color'.含める指定したパスが

DAL

public DBSet<Palete> Paletes {get; set; } 
public DbSet<Paint> Paints { get; set; } 

(注:modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

モデルを

public class Palete 
{ 
    public virtual Paint Paint { get; set; } 
} 

public class Paint 
{ 
    public string Color { get; set; } 
} 

query = query.Include(pal => pal.Paint.Color);

このエラーを修正するにはどうすればよいですか?

+2

正確なスペルは[palette](http://dictionary.reference.com/browse/palette)です... – Timwi

+0

@Timwi - fixed :) –

答えて

3

Colorは文字列プロパティです。Colorは別のエンティティを参照していないため、Includeは必要ありません。ただ

query = query.Include(pal => pal.Paint); 

をやって更新を考えると

は動作するはずです - あなたはPalleteエンティティを照会している場合。

+0

インクルード参照が実際にネストされています。より詳細な例を提供してください。 –

+0

ありがとう、あなたは正しいです。それにはオブジェクトが含まれます。 –

+0

なぜ、色だけが働かない(塗装には他の複数のフィールドがあると仮定しますか?) –

関連する問題