Home

Linqpad can't add row to table with rowguid default value

I have a table with replication enabled. This table added a rowguid column for replication purposes with a default value of (newsequentialid()).

When I use grid mode in linqpad to try to add a new row to this table, it doesn't use the default value and instead inserts a guid of 0000... when I'd prefer to submit the row with no value for rowguid, and allow it to be populated by executing the default value.

Is there a way to use the default value?

-Karl

Comments

  • I have the same problem, any solutions?
  • I'm also struggling with the same issue. Linqpad is an awesome tool, but as soon as we enable replication on our databases we can't insert or update data via Linqpad. I would think this is a very common scenario/issue. Any ideas/help would be greatly appreciated.
  • Unfortunately, this is a limitation of LINQ to SQL. There's no good workaround, other than perhaps recompiling the source code for LINQ to SQL, and adding this as a new feature. (And it would be a breaking change, so the feature would have to be switchable via an option on the connection dialog.)

    Entity Framework 6 has the same problem, FWIW. However, this has been fixed in EF Core. When EF Core matures, I'll add an automatic context-buildling driver to LINQPad for EF Core, so you'll be able to choose between LINQ to SQL or EF Core when automatically building a context. (Right now, it wouldn't be so useful, because EF Core still lacks some essential features.)
  • I know I've gotten around this issue with EF with other databases by setting the column's 'Store Generated Pattern' to 'Identity' in the .edmx file. I thought there was something similar for LINQ to SQL in the .dbml, but I can't remember for sure. It would be nice to be able to set that flag without having to generate an assembly and reference it.
  • There is a similar option in LINQ to SQL: flagging the column as IsDbGenerated allows inserts that preserve the default value. However, it also prevents that column from being updated later.
Sign In or Register to comment.