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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:57:38+00:00 2026-06-05T17:57:38+00:00

im using an adapter to be able to plug interfaces rather than concrete types

  • 0

im using an adapter to be able to plug interfaces rather than concrete types into dbcontext. the adapter works on its own, but im having trouble with getting the any one-to-one (parent child) relationships to be saved into the database:

Exception Source

public void SaveDomain(IDomain domain){
    _entityRepositor = new Donors();
    _entityRepositor.DomainReps.Add(new DomainRep(domain));                
}

InvalidOperationException

Conflicting changes to the role 'DomainRep_TopLevelDomainRep_Target' of the relationship 'Edonics.Repositor.DomainRep_TopLevelDomainRep' have been detected.

The Foreign Key Properties and the Navigation Properties Should Be in Sync?

public class DomainRep: IDomain
{
    private readonly IDomain _adaptee;        


    public DomainRep(IDomain adaptee)
    {
        _adaptee = adaptee;
    }

    [NotMapped]
    public IDomain Adaptee
    {
        get { return _adaptee; }
    }

    public string Id
    {
        get { return _adaptee.Id; }
        set { _adaptee.Id = value; }
    }

    public string TopLevelDomainRepId
    {
        get { return _adaptee.Tld.Id; }

        set { }
    }

    [ForeignKey("TopLevelDomainRepId")]
    public TopLevelDomainRep TopLevelDomainRep
    {
        get { return new TopLevelDomainRep(Tld); }
        set { Tld = value.Adaptee; }
    }

    public ITopLevelDomain Tld
    {
        get { return _adaptee.Tld; }
        set { _adaptee.Tld = value; }
    }

    public string SecondLevelDomainRepId
    {
        get { return _adaptee.Sld.Id; }  
        
        set { } 
    }

    [ForeignKey("SecondLevelDomainRepId")]
    public SecondLevelDomainRep SecondLevelDomainRep
    {
        get { return new SecondLevelDomainRep(Sld); }
        set { Sld = value.Adaptee; }
    }

    public ISecondLevelDomain Sld
    {
        get { return _adaptee.Sld; }
        set { _adaptee.Sld = value; }
    }
    
}

Any ideas?

  • 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-05T17:57:40+00:00Added an answer on June 5, 2026 at 5:57 pm

    Your adapter pattern interfere with how EF works. You are providing a different implementation for the navigational properties of the entity. For example, if you access TopLevelDomainRep property several times it will return multiple instances but with the same ID/Entity Key. EF handles only single instance per context for a given primary key value.

    Either you create a domain layer on top of EF entities or you use EF entities the way it was expected to.

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

Sidebar

Related Questions

I am able to fetch contacts using this code https://stackoverflow.com/a/1780818/992774 , it works perfectly
Im using the endless adapter http://github.com/commonsguy/cwac-endless however whenever i return false (because i dont
I need to send files using the BizTalk 2006 (non wcf) FTP adapter. After
I am building an app using listview and lazy adapter based on @fedor post
Just some background, sorry so long winded. I'm using the System.Data.SQLite ADO.net adapter to
I adapted the jQuery slider code from http://webdeveloperplus.com/jquery/featured-content-slider-using-jquery-ui/ into my website which is based
Using udev I have been able to get this information for a certain USB
Hi i am trying to a populate a spinner with strings using arrayadapter.but i
I have a custom cursor adapter I'm using to fill a ListView. The inflater
Rails 3.1, Ruby 1.9.2, using a SQL Server 2008 database through the activerecord-sqlserver-adapter gem.

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.