Entity Framework - The property cannot be configured as a navigation property -
i'm defining 2 entities following, strange behavior occurring:
[table("clienttypes", schema="dbo")] public clienttype { [key] public int id { get; set; } public string name { get; set; } } [table("clients", schema="dbo")] public client { [key] public long id { get; set; } [foreignkey("clienttypeid")] public int clienttypeid { get; set; } public virtual clienttype clienttype { get; set; } }
i'm getting clienttypeid
property filled value, clienttype
object filled nothing. can me this?
thank all!
the foreignkey
attribute have on wrong property.
the annotation may placed on foreign key property , specify associated navigation property name, or placed on navigation property , specify associated foreign key name.
- source
[foreignkey("clienttypeid")]
should decorate public virtual clienttype clienttype
instead,
or change [foreignkey("clienttype")]
, leave is.
Comments
Post a Comment