I have an Account object that contains an “Id” field, which is mapped to a View in the database:
public class Account : GeneralInfo
{
[Column("first_name")]
public string FirstName { get; set; }
[Column("last_name")]
public string LastName { get; set; }
public string Designation { get; set; }
[Column("full_name")]
public string FullName { get; set; }
public string Email { get; set; }
[Column("member_type")]
public string MemberType { get; set; }
[Column("status")]
public string Status { get; set; }
[Column("paid_thru")]
public DateTime? PaidThru { get; set; }
[Column("member_record")]
public bool MemberRecord { get; set; }
[Column("category")]
public string Category { get; set; }
public virtual Subscription Subscriptions { get; set; }
}
I also have a Subscription object that uses the same “Id” as the account object:
[Table("Subscriptions")]
public class Subscription
{
[Column("Id")]
public string ID { get; set; }
[Column("Balance")]
public decimal Balance { get; set; }
}
When I try to use “subscription” as a navigation property of account, I get an error saying: {"Invalid column name 'Subscriptions_ID'."}
How can I access “subscriptions” using the Account object?
Use the fluent API to map the Shared PK relationaship.