Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8338671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:40:03+00:00 2026-06-09T04:40:03+00:00

I have a (legacy) table with two guid fields. The second guid field can

  • 0

I have a (legacy) table with two guid fields. The second guid field can be null, but I want to auto-generate a non-dupe guid on insert using linq to sql. I have auto-sync set to “OnInsert” and Auto Generate Value set to True. But for some reason, it is not autogenerating/inserting guid values when the records are being put in the DB. I guess I could loop generating guids until I find one that is not in the DB and then add it in, but that does not seem very elegant. I am sure there is a better way to do this using linq to sql. Any suggestions on how to do this? Is it not making the guid because the nullable property is set to T?

enter image description here

I had a similar issue before, but learned how to change the properties of the ID field so that linq to sql could add the guid How do i prevent Linq from adding a GUID so that SQL server can do it? I can’t use that solution here because the guid in this case is nullable and is not the PK, so I can’t change the properties the way I did in the linked question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:40:05+00:00Added an answer on June 9, 2026 at 4:40 am

    I guess I could loop generating guids until I find one that is not in the DB…

    If you use Guid.NewGuid() to generate GUIDs, you should never generate two that are identical. If that happens, you will have just beaten absolutely incredible odds. It is safe to assume that Guid.NewGuid() will return a GUID that nobody on the planet has ever generated before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a legacy table, which I can't change. The values in it can
I have two fields: string date1 = 04/26/10; string date2 = 04/25/10; How can
I have many-to-many linking table between two entities, datacenters and projects, in legacy code.
I have a table which has essentially boolean values in a legacy database. The
I have a table that contains the stock. It's legacy database and the stock
I have a legacy data base and a relation one-to-one between two tables. The
I have a legacy table that has as a part of its natural key
I have a legacy table with about 100 columns (90% nullable). In those 90
I have two different existing Database design's in the legacy apps I inherited. On
I have a legacy table with composite keys that are mapped to 3 other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.