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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:53:38+00:00 2026-06-13T08:53:38+00:00

I got an entity LICENSE that contains some relationsships, including three 1..* relationships. I’m

  • 0

I got an entity “LICENSE” that contains some relationsships, including three 1..* relationships.
I’m working on a GUI + Manager to allow to edit the entity and save it again, later.
When I call the save event on a button I overwrite the properties and relationships of my pre loaded entity I’m editing by reading the values from my controls.

I’m changing three relationships by loading the new selected entity with the same ObjectContext and overwrite the relationship itself. in 2 of 3 cases it works perfectly. even in the last case, the relationship is changed (another entity is stored) successful and the saving process could be done very well. However, in the third case there is a weird behaviour I don’t understand neither know how to fix it:

When I change the entity of the relationship, it overwrites the ID of my LICENSE object, that makes no sense at all.

Here is the code:

GUI:

private LICENSE lizenz { get; set; } // in the load event, this object will be filled correctly

private string form2obj() // this method is getting called in my button save event
{
    //...
    // I removed some conditions (they all successed on testing, so believe my controls are set right on testing this
    this.lizenz.ADRESSE_KONTAKTE_Lieferant = LizenzManager.LoadContact(Convert.ToInt32(this.ddLieferantAnsp.SelectedValue)); // ADRESSE_KONTAKTE_Lieferant is a 1..* relationship, this.ddLieferantAnsp.SelectedValue contains the ID of the object I want to load into the relationship
    this.lizenz.ADRESSE_KONTAKTE_Betreiber = LizenzManager.LoadContact(Convert.ToInt32(this.ddBetreiberAnsp.SelectedValue)); // ADRESSE_KONTAKTE_Betreiber is a 1..* relationship, this.ddBetreiberAnsp.SelectedValue contains the ID of the object I want to load into the relationship
    this.lizenz.DB_TYPES = LizenzManager.LoadDatabaseType(Convert.ToInt32(this.ddDatenbanktyp.SelectedValue)); // DB_TYPES is a 1..* relationship, too, this.ddDatenbanktyp.SelectedValue contains the ID of the object I want to load into the relationship
    // last line overwrites this.lizenz.ID with the value of Convert.ToInt32(this.ddDatenbanktyp.SelectedValue), this is wrong
    //...
}

BLL (LizenzManager):

// context is the same ObjectContext in all three calls!
//...
public static ADRESSE_KONTAKTE LoadContact(int id)
{
    return context.ADRESSE_KONTAKTE.Where(x => x.ID == id).Single(); // this seems to success
}

public static DB_TYPES LoadDatabaseType(int id)
{
    return context.DB_TYPES.Where(x => x.ID == id).Single(); // this works, but it overwrites the ID of my LICENSE object I load this into ...
}
//...

As you see, the loading ways are pretty much the same, both tables got the ID column, but the last relation overwrites this.lizenz.ID with the ID of the DB_TYPES entity I load.

Could you explain me, how to fix this issue?

  • 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-13T08:53:39+00:00Added an answer on June 13, 2026 at 8:53 am

    Ok, this was a very tiny and stupid issue.

    When I was creating the relationship in the SQL Management Studio before, I forgot to set the correct foreign key in my LICENSE table. So it was still on ID and forced to overwrite the ID of my license entity when changing the relationship.

    Thanks to all people who took the time to read this question.

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

Sidebar

Related Questions

I've got the entity that contains @version field. Sometimes I need to update it
I've got some (Entity Framework 4) code that looks like this: class QueueItem{ public
I've got an MVVM application that uses Entity Framework 4.1, WPF and C#. I
I have got an Entity model which contains a collection of Message objects which
I've got a JPA entity Request, that owns a List of Answers (also JPA
I've got an entity with a few properties that gets used a lot in
I've got an Entity Framework 4 model. There's 2 tables in that model, Subscribers
I got a ADO.NET Entity Data Model that I want to use on several
I've got an Image entity (Spring Roo / JPA) that references images stored on
I got a Entity with a Integer @Entity(name=customer) public Customer { ... @Column private

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.