Northwind POCO [英] Northwind POCO
问题描述
我正在尝试使用EF4为Northwind数据库创建一个POCO。我遇到了表名Order Details有空格的问题。
如果我创建一个POCO类OrderDetails,它会抛出异常说 System.Data.SqlClient.SqlException:无效的对象名称'dbo.OrderDetails'。
I am trying to create a POCO with EF4 for Northwind db. I am running into problem where the table name Order Details has a space.
If i create a POCO Class OrderDetails it throws exception saying System.Data.SqlClient.SqlException: Invalid object name 'dbo.OrderDetails'.
public class OrderDetail
{
[Key]
public int OrderID {get;组; }
公共秩序令{get;组; }
公共产品{get;组; }
public double UnitPrice {get;组; }
public int Quantity {get;组; }
public int Discount {get;组; }
}
public class OrderDetail
{
[Key]
public int OrderID { get; set; }
public Order Order { get; set; }
public Product Product { get; set; }
public double UnitPrice { get; set; }
public int Quantity { get; set; }
public int Discount { get; set; }
}
推荐答案
您好,
默认情况下,如果您在EF设计器中导入订单明细表,设计人员将为订单明细表生成'_'(下划线)。请尝试添加下划线并查看问题是否发生变化。
By default, if you import Order Detail table in EF designer, the designer will generate a '_' (underline) for Order Detail table. Please try to add an underline and see if the issue changes.
祝你好运
这篇关于Northwind POCO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!