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 4059300
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:11:26+00:00 2026-05-20T15:11:26+00:00

I need to have an entity that has two separate candidate keys where one

  • 0

I need to have an entity that has two separate candidate keys where one of them is the primary key, which is a surrogate identity key, and another one that is an alternate key representing the real unique attribute. I need to have them both separately in my entity. Please note that I am not referring to composite or multi-column keys. Anyhow I need to have this on one of my entities in ADO.NET data model. Is it possible to do that? If yes please guide me.

The reason to have the second key is that I need another entity to have an association (and foreign key) relationship with first entity on the that key.

Update: I found a very similar situation to mine in the following question:
http://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/a248632a-d305-4c15-8e57-6742457cca94
It seems that EF v1 does not support this feature. Does anybody know if V4(literally the second version) has this feature or not? I have found the following but it does not seem to show any clues that this feature has been added to the current version: http://blogs.msdn.com/b/adonet/archive/2009/05/11/update-on-the-entity-framework-in-net-4-and-visual-studio-2010.aspx

  • 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-05-20T15:11:27+00:00Added an answer on May 20, 2026 at 3:11 pm

    Entity framework doesn’t support unique keys. In entity model your second key will be field as any other. You will not be able to create relations on that key and EF will not check that value of the key is unique. But if your model will be based on existing database with unique keys you will have this check on database layer.

    Support for unique keys has been hinted at by the EF team but remains unavailable as of .NET 4.5.

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

Sidebar

Related Questions

A have a JPA entity that has timestamp field and is distinguished by a
I have a Video entity that has multiple Genres, public class Video { public
I need to edit a row of data in an Entity that has a
I have a simple bean @Entity Message.java that has some normal properties. The life-cycle
I have a few models that need to have custom find conditions placed on
I need to have multiple forms in the same webpage, all of them POSTing
I need to have two way communication between threads in Tcl and all I
I need to have a string, based on an integer, which should always have
I have a class called Entity, with two child classes: Creature and Item. (I'm
I have problem with two parts of database diagram and I need your guidance:)

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.