Home Dashboard Directory Help

Linq-to-SQL: Auto-generated column insert fails if the column name in the database and member name in the object model differs by KristoferA - Huagati Systems


 as Fixed Help for as Fixed

Sign in
to vote
Type: Bug
ID: 381883
Opened: 11/13/2008 10:51:46 PM
Access Restriction: Public
User(s) can reproduce this bug


The "output inserted.[fieldname] into ..." clause generated by Linq to SQL when inserting in a table with an autogenerated column (member properties Auto Generated Value = true and Auto-Sync=OnInsert) incorrectly uses the object model name in the generated SQL.

The column name used in the "output" clause of the insert statement is from the Column/@Member attribute rather than from Column/@Name, resulting in a SQL error.
Sign in to post a comment.
Posted by subkamran on 8/3/2009 at 4:31 AM
I mentioned this in my validation comment, but it seems this only affects GUID columns. Other data types seem to work just fine.
Posted by KristoferA - Huagati Systems on 3/26/2009 at 5:19 PM
Hi Sarah,

Great to hear, thanks!

Best regards,
Posted by Microsoft on 3/26/2009 at 2:02 PM
FYI, I am also fixing the resolution so it should show up as "Fixed" instead of "Won't Fix". I'm not sure how soon it will propagate that change, but regardless, this *has* been fixed.

Posted by Microsoft on 3/26/2009 at 1:59 PM

The fix for this bug will be included in .NET Framework 4.0.

Sarah Parra
LINQ to SQL Team
Posted by Microsoft on 12/3/2008 at 11:10 AM
Thank you for your feedback. We’ll look into this issue for a later release.

If you have any other feedback or concerns, please let us know.

Thank you
Data Programmability Tools Team
Posted by KristoferA - Huagati Systems on 11/23/2008 at 7:52 PM
Users of Huagati DBML Tools that are affected by this bug can find more information here:
Posted by KristoferA - Huagati Systems on 11/17/2008 at 1:47 AM

a clarification: the references to Column/@Member and Column/@Name above refers to the storage location of the names in the DBML. In other words, the generated SQL uses the property's member name instead of the name from the "[Column(Name=..." attribute.

E.g. "TestTableID" instead of "test_table_id" from this example:

public Guid TestTableID
Posted by Microsoft on 11/17/2008 at 1:08 AM
Thanks for your feedback. We are escalating this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team
Sign in to post a workaround.
Posted by Simon Hughes on 2/20/2009 at 1:48 AM
Thanks Anders.
Thumbs down for Microsoft. This is a genuine "staring you in the face" bug, and they won't fix it?
Posted by KristoferA - Huagati Systems on 11/23/2008 at 7:39 PM
Workaround 1: give the member property the same name as the underlying db field.

Workaround 2: for users of Huagati DBML Tools that are affected by this bug - as of version 1.48 the add-in will make the member property name identical to the column name for all autogen+oninsert members to avoid running into this bug.

Once (or if) MSFT releases a fix, this workaround in the add-in can be turned off by changing the "Disable381883" flag in the add-in's .syncprefs file to "true".