Let's say I have a data model that looks like so:
dbo.Application
{
int Id { get; set; }
int ClientAlternateId { get; set; }
...
public virtual Client Client { get; set; }
}
dbo.Client
{
int Id { get; set; }
int AlternateId { get; set; }
string Name { get; set; }
...
}
Where the primary key on both tables is the Id
column. the Application
type is associated to the Client
table via its AlternateId
column (which is not a key). The data in this column is always unique.
Is there a way to get entity framework to map this? I don't believe I'll be able to use:
HasRequired(t => t.Client).WithMany().HasForeignKey(c => c.ClientAlternateId);
since that field is not the primary key.