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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:53:28+00:00 2026-06-16T19:53:28+00:00

I use EF 4. Having this code to test the functionality of my model.

  • 0

I use EF 4.
Having this code to test the functionality of my model.

    using (var context = new CamelotDB())
    {
        Console.WriteLine("Starting User Repository Testing{0}",Environment.NewLine);
        Console.WriteLine("Creating Test User");
        DomainEntity userToAdd = new User()
        {
            EntityName = "Test User",
            EntityType = DomainEntity.eEntityType.User,
            Username = "TestUser",
            Password = "123",
            Email = "TestUser@Test.org",
            FirstName = "Test",
            LastName = "User",
            Phone = "123456789",
            EntityParentID = null,
        };

        Console.WriteLine("Saving user to database...");
        userToAdd = context.DomainEntities.Add(userToAdd);
        context.SaveChanges();

        Console.WriteLine("Fetching user from database...");
        int userID = userToAdd.EntityID;
        DomainEntity userToDelete = context.DomainEntities.Find(userID);

        Console.WriteLine("Removing the user...");
        context.DomainEntities.Remove(userToDelete);
        context.SaveChanges();

    } 

The user adds successfully to the DB and i get back the userID.
When I try to use the Find() method in

DomainEntity userToDelete = context.DomainEntities.Find(userID);

I get the following error: value cannot be null. parameter name key

I event tried to call the follwing:

DomainEntity userToDelete = context.DomainEntities.Find(2);

Knowing that the userID 2 exists in the DB but still got the same Exception.

  • 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-16T19:53:29+00:00Added an answer on June 16, 2026 at 7:53 pm

    Got it fixed somehow… just removed the key property from the EDMX and added it again the save changes and everything went back to normal guess it was something to do with the EDMX generation…

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

Sidebar

Related Questions

I have an issue. I use this code: var test='test'; $('#tip').delay(1000).html(test); That doesn't work,
I'm having trouble using gsub correctly: Given this code: replace me.gsub(/replace me/, this \\0
Having this code in a test.md file $$ \begin{aligned} 20x 1 \leqt 70 \end{aligned}
This code now works. I'm having an issue inserting a new blog post on
I am trying to convert this test code to C# and having a problem
I'm having this issue where i use nth-child(odd) to color a table. In IE9
i am having this problem try to use the cocos2d CCScrollLayer I have added
I'm having this issue when trying to use an ASPX page from a referenced
I'm trying to use Jake Wharton's TitlePageIndicator and having this issue. In the getTitle()
I originally used JQuery for this project, but now I'm having to use Prototype,

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.