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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:15:51+00:00 2026-05-15T15:15:51+00:00

I’m working with a bit of a legacy database, but here’s the basic idea:

  • 0

I’m working with a bit of a legacy database, but here’s the basic idea:

Item
Id INT PK NOT NULL
Description VARCHAR(50) NOT NULL
TranslationId INT NULLABLE

Translation
Id INT PK NOT NULL
Language VARCHAR(10) PK NOT NULL
Translation VARCHAR(50) NOT NULL

Basically every Item MAY have many Translations, seems simple enough. These tables don’t have foreign keys, so I’m manually trying to create the association in the DBML, however it fails because of the NULL difference between translationID and the PK in the Translation table.

Is there anyway I can get this association to work, eg:

item.Translations

Error message:
Cannot create an association “Item_Translation”. Properties do not have matching types: “TranslationId”, “Id”.

I know it has to do with TranslationId being nullable because another another table with an association to Translations works correctly, however its TranslationId column is NOT NULL.

Sample data from Translation:

Id Language Translation
1  en-us    some text
1  en-gb    some text
2  en-us    some text
2  en-gb    some text
  • 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-15T15:15:52+00:00Added an answer on May 15, 2026 at 3:15 pm

    Currently you have this set up so that a translation can have many items, not the way you state where an item can have many translations.  To fix that, you need an itemId in your Translation table, and to remove the translationId from your Item table.

    Once you get that taken care of, if you are having trouble, please post the error message you are getting.

    EDIT:

    LINQ 2 SQL is not built to recognize what you are trying to do.  When you create a foreign key, you can say it in words, the parent has many children.  The parent has the primary key, and the child table has the pointer to that primary key (the foreign key).  How you have set this up is the opposite.  In your case, you are linking not the full primary key, but instead an portion of the primary key which provides enough information to invert the relationship.

    I understand your issue with needing to link the translations table from multiple tables, so I would normally argue for a redesign here.  Since it seems to do what you are looking for, I will save that for another thread.  My suggestion is to add your own property to the classes, and remove the association in the designer.

    You can right click anywhere in the designer and choose View Code, then just manually add the property:

        

    namespace MyNamespace
    {
        // put your using statements inside the namespace for this file!!!
    
        partial class Item
        {
            public IQueryable<Translation> Translations
            {
                MyDataContext dc = new MyDataContext();
                return dc.Translations.Where(t => t.Id == this.translationId);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.