I've tried to work this out myself, but i'm not a database guy and it has confused me heavily.
I have two classes (cut down for ease of reading)
public class Project : IModel
{
//Internal DB Id
[DataMember]
public int ProjectID { get; set; }
//Project No - Auto Generated at service level
[DataMember]
public string ProjectNo { get; set; }
}
public class ProjectExtra : IModel
{
[DataMember]
public int ProjectID { get; set; }
[DataMember]
public string Description { get; set; }
}
These are used to generate my database using EF6, however I need to mark the ProjectID in ProjectExtra as both the PK and the FK, and i cannot work out how to do that with Fluent API.
ProjectExtra is optional, it may exist once for a project, or not at all.
Can someone perhaps point me in the right direction, I have already setup a couple of others in the method
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Project>().HasMany(p => p.Managers).WithMany();
modelBuilder.Entity<Project>().HasMany(p => p.Clients).WithMany();
}