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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:40:56+00:00 2026-05-26T18:40:56+00:00

I ran into an issue when adding two navigation properties of the same type

  • 0

I ran into an issue when adding two navigation properties of the same type in a model, giving me this error :

System.Data.SqlClient.SqlException: 
Invalid column name : 'Createur_IdUtilisateur'.
Invalid column name : 'Proprietaire_IdUtilisateur'.

This is the code (broken) that I have :

public class Billet
{
    [Key]
    public int IdBillet { get; set; }
    public int IdMandat { get; set; }
    public string Titre { get; set; }
    [AllowHtml]
    public string Description { get; set; }
    public int IdUtilisateurCreateur { get; set; }
    public int IdUtilisateurProprietaire { get; set; }
    public DateTime DateCreation { get; set; }
    public DateTime? DateFermeture { get; set; }
    public int EstimationTemps { get; set; }
    public int Priorite { get; set; }
    public bool FermetureParCreateur { get; set; }

    public virtual ICollection<Intervention> Interventions { get; set; }
    public virtual Mandat Mandat { get; set; }
    public virtual Utilisateur Createur { get; set; }
    public virtual Utilisateur Proprietaire { get; set; }
}

public class Utilisateur
{
    [Key]
    public int IdUtilisateur { get; set; }
    public int IdUtilisateurRole { get; set; }
    public string Courriel { get; set; }
    public string Nom { get; set; }
    public string Password { get; set; }
    public bool Actif { get; set; }

    public virtual UtilisateurRole Role { get; set; }
}

And this is what the relationships look like in the database.

database relationships

I’ve read about [InverseProperty], but I’m not sure how I would go about implementing that in my situation. Do I need to add reverse navigation properties in my Utilisateur class to make this work?

  • 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-26T18:40:57+00:00Added an answer on May 26, 2026 at 6:40 pm

    Shortly after asking I realized my mistake, this is how I fixed it :

    public class Entities : DbContext
    {
        ...
    
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            ...
    
            modelBuilder.Entity<Billet>()
                .HasRequired(b => b.Createur)
                .WithMany()
                .HasForeignKey(b => b.IdUtilisateurCreateur);
            modelBuilder.Entity<Billet>()
                .HasRequired(b => b.Proprietaire)
                .WithMany()
                .HasForeignKey(b => b.IdUtilisateurProprietaire);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This morning I ran into an issue with returning back a text string as
I ran into this issue when trying to add a CMFCMenuButton to an existing
Yesterday I ran into an Issue while developing a Web Part (This question is
Yesterday I ran into an issue with PHP's strtotime not properly adding a month.
Ran into this issue yesterday on one of our sites. First of all the
I ran into an issue with an IIS web app shutting down an idle
I ran into an issue with something that I am probably just overlooking. I
I ran into an issue by introducing floating point columns in the MySQL database
I recently ran into a issue where intermediate link betweeen a TCP server and
I just ran into an issue with Python's imaplib and Gmail's authentication mechanism: >>>

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.