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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:37:50+00:00 2026-06-12T04:37:50+00:00

I have a table in my db (a many to many table) that two

  • 0

I have a table in my db (a many to many table) that two classes A and B have created like this.

    this.HasMany(t => t.TrafficImageQuestions)
       .WithMany(t => t.TrafficImages)
        .Map(m =>
            {
                m.ToTable("TrafficImage_Answers");
                m.MapLeftKey("TrafficImagesGuid");
                m.MapRightKey("TrafficImageQuestionsId");


            });

Now i would like to assosiate my custom class to this same table “TrafficImage_Answers”, the class offcause have the left and right key and then also a 3. custom property.

(i did add the column to the database “Answer”)

    public class TrafficImageAnswer
    {
        public System.Guid TrafficImageGuid { get; set; }
        public int TrafficImageQuestionId { get; set; }
        public byte Answer { get; set; }
    }

I am doing this as i want entity model to keep track of my many to many relationship of A and B and still be able to look up the 3. property Answer that is in the database.

What i have tried

I tried to do the following:

    this.Property(t => t.TrafficImageQuestionId)
        .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
    this.Property(t => t.TrafficImageGuid)
        .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

    // Table & Column Mappings
    this.ToTable("TrafficImage_Answers");

But i get that the table already exists, logic. I need to tell it that it just should use that table and not try to create it.
(im doing this with DB mitigrations in EF 5 and Package manager).

  • 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-12T04:37:51+00:00Added an answer on June 12, 2026 at 4:37 am

    That is not supported. If you want to have additional field in the junction table for many-to-many relation you cannot map it as many-to-many any more. Each table can be mapped only once but mapping table to entity and to many-to-many relation in the same time makes it mapped twice.

    You must change your TrafficImageQuestions and TrafficImages to use one to many relations with TrafficImageAnswer instead of many-to-many relation with each other.

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

Sidebar

Related Questions

I have a table, say STUDENTS, that is related one-to-many to another table, CLASSES.
I have two tables (TABLE1, TABLE2 - unique i know) that has a 1-to-many
I have a MySQL table that holds many entries with repeated IDs (for various
i have a many to many table relationship that involves 2 logical tables. Record
I have a table within my database that has many records, some records share
I have some tables that benefit from many-to-many tables. For example the team table.
I have two classes: sample, and parameter. I also have a sample_sample_parameter lookup table
I have defined a many-to-many relationship between my two entity classes User and Permission.
I have modeled two classes with a many to many relationship : User and
Database structure I have two classes, A and B, that have two different relationships:

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.