Is there a way to generate the ForeignKey below in Fluent API on Model Mapping or ModelBuilder Conventions/Annotations? I'm using the EF6.
I was able to create the needed foreign key changing manually after creating a migration! Works as expected... but what i need is creating a automated process for some foreign keys!
.ForeignKey("dbo.Client", t => new { t.ClientId, t.CompanyId }, cascadeDelete: false)
The entire migration:
public override void Up()
{
CreateTable(
"dbo.Orders",
c => new
{
Id = c.Int(nullable: false, identity: true),
CompanyId = c.Int(nullable: false),
ClientId = c.Int(nullable: false),
Desc = c.String(maxLength: 80)
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.Company", t => t.CompanyId, cascadeDelete: false)
.ForeignKey("dbo.Client", t => new { t.ClientId, t.CompanyId }, cascadeDelete: false)
.Index(t => t.CompanyId)
.Index(t => t.ClientId);
}