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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:35:05+00:00 2026-06-11T20:35:05+00:00

I am trying to create an Entity key for a table, in order to

  • 0

I am trying to create an Entity key for a table, in order to insert a row in the table without loading the related tables.

I am trying to use this contructor: http://msdn.microsoft.com/en-us/library/bb739024.aspx

The code example in the above link uses a different contructor.

The code I have so far is:

KeyValuePair<String, Object> key1 = new KeyValuePair<string,object>("MainId", 1);
KeyValuePair<String, Object> key2 = new KeyValuePair<string,object>("SubId", 2);


List<KeyValuePair<String, Object>> keyList = new List<KeyValuePair<String, Object>>();
keyList.Add(key1);
keyList.Add(key2);


EntityKey entitykey = new EntityKey(

How can I complete the creation of the entity key?

  • 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-11T20:35:06+00:00Added an answer on June 11, 2026 at 8:35 pm
    object value = null;
    keyList.TryGetValue("MainId", out value);
    EntityKey entitykey = new EntityKey("EntitySetName.TableName", "FieldName", value);
    

    Edit:
    To add multiple keys:

    IEnumerable<KeyValuePair<string, object>> entityKeyValues =
     new KeyValuePair<string, object>[] { new KeyValuePair<string, object>("Key", "Value") };
    EntityKey key = new EntityKey("EntitySetName.TableName", entityKeyValues);
    

    That should do the work.

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

Sidebar

Related Questions

I'm trying to create one entity from 2 tables that are related not by
I'm trying to use a view to create an ADO.NET entity using a view.
I’m trying to get Entity Framework to create the tables in a certain way
I'm trying to map via DbModel this relationship present on the database. CREATE TABLE
I am trying to create an entity for the table structure given belos (id,
I'm trying to create an entity in Symfony2 that the primary key based on
I am having a trouble while trying to create an entity with a custom
I'm trying to create ASP.NET MVC Application with Entity Framework, which has One to
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I'm trying to realise this table structure: http://www.img-teufel.de/uploads/Unbenannt1d4f8a349jpg.jpg (not embedded due to size) It

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.