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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:21:46+00:00 2026-05-23T03:21:46+00:00

I am struggling on how to map these two tables together, the Column TitleID

  • 0

I am struggling on how to map these two tables together, the Column TitleID on the Name table maps to the TitleID on the Title table. The table primary keys are NameTableID / TitleTableID and are unique, NameID, TitleID (on both tables) are not unique, the current record is found by a null in the DateEnd column.

public class Name
{
    public int NameTableID { get; set; }
    public int NameID { get; set; }
    public int TitleID { get; set; }    // Maps to Title.TitleID
    public virtual Title Title { get; set; }
    public string GivenName { get; set; }
    public string FamilyName { get; set; }
    public DateTime DateStart { get; set; }
    public DateTime? DateEnd { get; set; }
}
public class Title
{
    public int TitleTableID { get; set; }
    public int TitleID { get; set; }    // Maps to Name.TitleID
    public string Description { get; set; }
    public DateTime DateStart { get; set; }
    public DateTime? DateEnd { get; set; }
}

I am assuming I need to add a bit of code to OnModelCreating in my DB Context class, but am struggling with the mapping / code, any ideas?

Thanks,
Martin

  • 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-23T03:21:47+00:00Added an answer on May 23, 2026 at 3:21 am

    This is not relation at all. You cannot build relation on two arbitrary columns. You should read some introduction about how database relations work and what are requirements to build a relation.

    In many-to-many you must choose unique key on both ends and there must be junction table which will build pairs of related keys. EF doesn’t support unique keys so the only way how to build many-to-many relation is on top of primary keys: If you want many-to-many relation you must build it on Title.TitleTableID and Name.NameTableID.

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

Sidebar

Related Questions

Struggling getting a query to work…….. I have two tables:- tbl.candidates: candidate_id agency_business_unit_id tbl.candidate_employment_tracker
I'm struggling on how to map out the model for a database I'm looking
I'm gluing together a number of system calls using the Amazon Elastic Map Reduce
Im not sure this can be done, basically I'm struggling to map c# objects
I'm designing a map for a browser based game, and I'm really struggling getting
I'm struggling trying to cluster 50 markers using the markerclusterer v3 with Google maps
I have a little problem with a Google Maps page I have put together.
I am struggling trying to persist a map to SQLserver with the code below
I am struggling to get Fluent NHibernate and the NHibernate Validator working together and
I'm struggling with turning on the Map Control in Leaflet. Staring at the example

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.