Northwind POCO

编程入门 行业动态 更新时间:2024-10-25 18:27:09
本文介绍了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

本文发布于:2023-07-27 11:49:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1222296.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Northwind   POCO

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!