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

  • SEARCH
  • Home
  • 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 9235549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:04:30+00:00 2026-06-18T07:04:30+00:00

I have a CodeFirst Entity Framework database. I am generating a GUID myself, and

  • 0

I have a CodeFirst Entity Framework database. I am generating a GUID myself, and the following is defined in the model:

    [Required, Key, DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None)]
    public string BatchId { get; set; }

My goal – is there a way I can first validate that the GUID does not already exist in the database, and then create a new GUID as needed until a unique one is found?

  • 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-18T07:04:32+00:00Added an answer on June 18, 2026 at 7:04 am

    By all means read the DB first to be sure to be sure. But E=MC^2 or your money back.

    Context.DbSet.find(MyGuid);
    

    Nope not found….
    Let us know when you get a dup if using Guid.New();

    Btw do you plan on using strings for your gUid or type Guid / DBType UniqueIdentier ? If so, You should reconsider the type chosen.

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

Sidebar

Related Questions

Using the Entity Framework Code First paradigm I have defined the following objects and
I have a pre-defined database that I want to map using Entity Framework 4
I'm having lots of trouble with codefirst Entity Framework. I have a database with
I have an issue in entity framework code first, three table in database as
I have a system in production which was created with Entity Framework 4.1 Code
Using the Entity Framework 4. I have created a Code First database in the
I have built up a code-first model using Entity Framework 5. The classes have
I have following C# code that uses Entity Framework Code First approach. The tables
I have a ASP.NET MVC 4 project - CodeFirst with Entity Framework - that
I am using the code-first approach in Entity Framework 4.0. I have defined an

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.