Linq to SQL .DBML 子属性问题
我的 .DBML 中的表“A”和“B”之间存在 1:1 关系。数据库中的 FK 已就位,.DBML 图显示“A”和“B”之间的关联线。但是,我无法让代码生成器在“A”实体中创建子属性。我只有FK专栏。在关联属性中,我将 ChildProperty 设置为 true。但是,代码生成器不会创建子属性。我已经多次删除和添加这两个表。
有人有什么想法吗?
I have a 1:1 relationship between table 'A' and 'B' in my .DBML. The FK in the database is in place and the .DBML diagram shows an association line between 'A' and 'B'. However, I cannot get the code generator to create a child property in the 'A' entity. All I have is the FK column. In the Association properties, I have ChildProperty set to true. However, the code generator will not create the child property. I have dropped and added the two tables several times.
Anyone have any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果关联表之一缺少主键,O/R 设计者将拒绝创建关联属性。确保所有关联的表都有主键。
The O/R designer will refuse to create an association property if a primary key is missing on one of the associated tables. Make sure all of your associated tables have a primary key.
不确定,但我认为您所说的 1:1 实际上被 DBML 视为 1:*,因为该列表可以“拥有”您的许多 fk 表,例如,一个员工可以拥有一个城市,但每个城市都可以“拥有”多名员工。
AFAIK 每个表中的主键是先决条件,没有它 DBML 将无法“工作”。保存时出现错误。您的项目将编译,但稍后您会看到错误。华泰
Not sure, but I think what you call 1:1 is actually seen by the DBML as 1:* because the list can "have" many of your fk-table, e.g. one empley oyee can have one city, but each city can "have" many employees.
AFAIK a primary key in each table is a prerequisite without which the DBML will not "work". An error is issued when saving it. Your project will compile, but you'll see the errors later. HTH