开发者

Linq to SQL .DBML Child Property Problem

开发者 https://www.devze.com 2023-02-16 13:54 出处:网络
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 开发者_Go百科diagram shows an association line between \'A\' and \'B\'. However, I

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 开发者_Go百科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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号