No the second table does not have a primary key. It does not contain any
fields that are unique.
The Part field in the tblPart can contain the same part number several times
in the table.
> No the second table does not have a primary key. It does not contain any
> fields that are unique.
>
> The Part field in the tblPart can contain the same part number several times
> in the table.
I suspect that LINQ to SQL won't like that. Many ORMs have difficulty
with situations like that, particular because it makes it basically
impossible to update the entity. I can see how you may not need a PK
when using SQL directly if you're just reading from the table, but I'd
advise including one anyway.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jialiang Ge [MSFT] - 17 Mar 2008 08:29 GMT
Hello SftwDude and Jon,
Yes, indeed. You are right. The warning message "DBML1062" is due to the
lack of PK in the table tblPart. We also received several reports of this
problem in MSDN forum:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2510382&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2896891&SiteID=1
And the resolution is to, as Jon said, add a PK to the table.
SftwDude, though the second table (tblPart) does not contain any fields
that are unique, we can add a PK to it in one of the following ways:
Method 1. Add an int-typed column (e.g. tblPartID) to the table tblPart,
and fill the value 1, 2, 3, 4¡ to this column for the existing items. Then
set the PartID column as PK, and set its Identity Specification as True in
SQL Server Table designer so that when new item is inserted into the table,
the value of PartID could be automatically generated.
Method 2. In the table tblPart, if multiple columns together (e.g. the
combination of part number and part name) can identify one item, we can
turn the fields into a PK:
alter table tblPart add constraint applied_tags_PK primary key
(part_number, part_name);
If you have any other concerns or questions, please feel free to let me
know.
Regards,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
SftwDude - 17 Mar 2008 13:07 GMT
Thanks Jon and Jialiang.
It added an Identity field and made it a Primary Field as you suggested.
This works, now I get the power of having non flat entity and having the
DataContext managing CRUD and concurrency, etc...
I was reluctant to add a field to the table that is not necessary, but the
benefit out ways the additional field.
Thanks again
Jialiang Ge [MSFT] - 18 Mar 2008 03:49 GMT
No problem. You are welcome. :-)
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================