Order Model
public partial class Orden
{
public Orden()
{
this.Orden_Bitacora = new HashSet<Orden_Bitacora>();
}
//Attributes list
public virtual ICollection<Orden_Bitacora> Orden_Bitacora { get; set; }
}
Orden_Bitacora Model
public partial class Orden_Bitacora
{
public int IdBitacora { get; set; }
public int IdOrden { get; set; }
public virtual Orden Orden { get; set; }
}
But when I try to create a Order
always display me the message:
Schema specified is not valid. Errors:
The relationship 'OrdenexTModel.FK_Orden_Bitacora_Orden' was not loaded because the type 'OrdenexTModel.Orden' is not available.
Its something wrong with the model declaration?
The relationship 'OrdenexTModel.FK_Orden_Bitacora_Orden' was not loaded because the type 'OrdenexTModel.Orden' is not available.
It cant find a Primary Key on Ordan and therefore the FK relationship will not work. Add the PK to Orden
public partial class Orden
{
public int OrdenId { get; set; }
public Orden()
{
this.Orden_Bitacora = new HashSet<Orden_Bitacora>();
}
//Attributes list
public virtual ICollection<Orden_Bitacora> Orden_Bitacora { get; set; }
}
and you may need to add [Key] attribute to your Orden_Bitacora PK as it doesnt follow the Entity Framework naming convention
[Key]
public int IdBitacora { get; set; }
or
public int Orden_BitacoraId
Hope that helps