Linq to SQL.DBML Child Property Problem

I have a 1: 1 ratio between tables "A" and "B" in my .DBML. The FK in the database is in place, and the .DBML diagram shows the link between “A” and “B”. However, I cannot force the code generator to create a child property in entity "A". All I have is an FK column. In association properties, I have a ChildProperty property equal to true. However, the code generator will not create a child property. I dumped and added two tables several times.

Does anyone have any idea?

+6
linq linq-to-sql
source share
2 answers

The O / R designer will refuse to create an association property if there is no primary key in one of the linked tables. Make sure all tables associated with it have a primary key.

+16
source share

Not sure, but I think what you call 1: 1 is actually prominent DBML as 1: *, because a list can "have" many of your fk tables, for example. one emley oyee may have one city, but each city may “have” many employees.

AFAIK the primary key in each table is a prerequisite without which DBML will not "work". When you save it, an error occurs. Your project will compile, but you will see errors later. NTN

0
source share

All Articles