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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:52:57+00:00 2026-06-18T18:52:57+00:00

I tried following code with following designed model. First call to SaveChanges() is succeed

  • 0

I tried following code with following designed model.
First call to SaveChanges() is succeed but not when it comes to second call.

I have already worked 18 hours on this and can’t figure out what is the problem.
Specially when I can achieve the code goal manually with MSSQL server explorer !

Can anyone provide me a solution ?

enter image description here

        var mc = new Model1Container1();

        mc.Categories.Add(new Category() { Text = "Laptop" });
        mc.Categories.Add(new Category() { Text = "TV" });
        mc.SaveChanges();

        var cat = mc.Categories.Where(c => c.Text == "Laptop").FirstOrDefault();
        CKey ck = new CKey() { Key = "RAM" };
        cat.CKeys.Add(ck);

        for (int i = 1; i < 100; i++)
        {
            var ia = new Item() { Text = "MSI GX780-R", Category = cat };

            ia.CProperties.Add(new CProperty() { Value = "4GB", CKey = ck });

            mc.Items.Add(ia);
            mc.SaveChanges();
        }
  • 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-18T18:52:59+00:00Added an answer on June 18, 2026 at 6:52 pm

    You are trying to associate the same CKey instance to 100 instances of CProperty, but according to the graph of multiplicities, a given instance of CKey can only be associated to at most 1 CProperty.

    Either create a new instance of CKey in each iteration of the loop, or modify your schema.

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

Sidebar

Related Questions

I have tried the following code but has no effect: Imports system.Runtime.InteropServices <DllImport(UxTheme.DLL, BestFitMapping:=False,
I tried the following code. Although I don't get any errors, it did not
I just tried the following code, but the result seems a little strange. It
I have tried the following code: $('a.buildMenu').click(function (event) { // Prevent normal behaviour event.preventDefault();
I am currently working on Problem 62 I have tried the following code to
Had tried following code in Linux, but always return 'C' under different LANG settings.
I have the following code (VB.NET) which is designed to determine if a given
I have written the following code designed for API version 2.3.3 minimum and works
I want to get script's origin filename in global functions. I tried following code,
I tried the following code tree. If I put the header file hello.h into

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.