[英]EntityFramework Schema specified is not valid. Errors:
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 Orden_Bitacora 模型
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:但是,当我尝试创建
Order
总是向我显示以下消息:
Schema specified is not valid.
指定的架构无效。 Errors:
错误:
The relationship 'OrdenexTModel.FK_Orden_Bitacora_Orden' was not loaded because the type 'OrdenexTModel.Orden' is not available.
关系“OrdenexTModel.FK_Orden_Bitacora_Orden”未加载,因为类型“OrdenexTModel.Orden”不可用。
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.关系“OrdenexTModel.FK_Orden_Bitacora_Orden”未加载,因为类型“OrdenexTModel.Orden”不可用。
It cant find a Primary Key on Ordan and therefore the FK relationship will not work.它无法在 Ordan 上找到主键,因此 FK 关系将不起作用。 Add the PK to Orden
将PK添加到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] 属性添加到您的 Orden_Bitacora PK,因为它不遵循实体框架命名约定
[Key]
public int IdBitacora { get; set; }
or或者
public int Orden_BitacoraId
Hope that helps希望有帮助
转到 EntityFramework .edmx 文件,该文件将打开一个实体框架,右键单击并选择从数据库更新模型,选择 oky 它将在数据库中进行更改时进行更新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.