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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:07:29+00:00 2026-05-29T11:07:29+00:00

I have this problem: have two entyties with one to one relationship, boot of

  • 0

I have this problem:

have two entyties with one to one relationship, boot of them has the same Id Column name

    Document_head                sales_Order 
+-----------------+         +------------------+
+ DocumentId      +         + DocumentId       +
+ Person          + 1-----1 + OrderDate        +
+ Status          +         + Purchaser        +
+ ...             +         + ...              +
+ ----------------+         +------------------+ 

Here is the entity definition

public partial class Document_head
{

    public Document_head()
    {
       // Other 
    }
    [Key]
    public string DocumentId {get;set;}
    public int PersonId {get;set;}
    public int status {get;set;}

    [ForeignKey("DocumentId")]
    public virtual sales_Order sales_Order { get; set; }
}


public partial class sales_order
{
    public sales_order()
    {
        //Other
    }
    [Key]
    public string DocumentId  { get; set; }

    public virtual Document_head Document_head { get; set; }
}

Here is the context

public class MyContext : DbContext
{
    public DbSet Document_head Document_head{ get; set; }
    public DbSet<sales_order> sales_order{ get; set; }

    modelBuilder.Entity<Document_head>()
        .HasOptional(p => p.sales_order).WithRequired();
    modelBuilder.Entity<sales_order>()
        .HasRequired(p => p.Document_head).WithOptional();
}

The problem is when run the MVC3 application.

it say:

The Column Name “Document_Head_DocumentId” is not valid.

I’m spending many time with this situation, if somebody could help me with this .. would be very appreciated.

  • 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-05-29T11:07:29+00:00Added an answer on May 29, 2026 at 11:07 am

    Change the configuration as follows. You need only single configuration line and that should include both navigational fields.

    public class MyContext : DbContext
    {
        public DbSet Document_head Document_head{ get; set; }
        public DbSet sales_order{ get; set; }
    
        modelBuilder.Entity‹sales_order›().HasRequired(p => p.Document_head)
             .WithOptional(p => p.sales_order);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i'm having this problem. I have two tables (Oracle), one is called Destination
I have had this problem w/ two seperate WYSWYG editors in my rails application
I have this little problem. My client wanted two distinct swf on a web
I am wondering how you would approach this problem I have two Taxrates that
My problem is this: I have two threads, my UI thread, and a worker
I have a problem with IE causing two errors: 1. Object doesn't support this
I have two entities, Job and Language , in a many-to-one relationship. The mapping
I have two processes that work with data in the same table. One process
I have this problem I'm hoping someone knows the answer to. I have an
I have this problem where I open Visual Studio and the internal windows are

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.