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
转到 EntityFramework .edmx 文件,该文件将打开一个实体框架,右键单击并选择从数据库更新模型,选择 oky 它将在数据库中进行更改时进行更新。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.