I have the following table definition:
public partial class ClientClassification
{
[Key, Column(Order = 0)]
public long ClientId { get; set; }
[Key, Column(Order = 1)]
public ClientClassificationEnum ClientClassificationType { get; set; }
[ForeignKey("ClientId")]
public virtual Client Client { get; set; }
}
ClientId is a foreign key into the Client table. This is a many to 1 relationship (a client can have many classifications). Is there any way I can omit the Client navigation property but still declare this foreign key relationship? So something like:
public partial class ClientClassification
{
[Key, Column(Order = 0)]
[ForeignKey("Client.ClientId")]
public long ClientId { get; set; }
[Key, Column(Order = 1)]
public ClientClassificationEnum ClientClassificationType { get; set; }
}
Since there will be no relationship between "classes" and still you want to create the relationship on the dtaabase, I would be using a migration script to do it (and no annotations on the class).
If you would still like to have the annotation on the class (for a reason that I can't imagine right now) you could then declare a protected Client attribute (this way you would be declaring the Client navigation property but it wouldn't be accessible for anyone but inherited classes).