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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:26:38+00:00 2026-06-10T20:26:38+00:00

I have 2 entities: public class User { public int userId { get; set;

  • 0

I have 2 entities:

public class User
{
  public int userId { get; set; }
  public string name { get; set; }
  public Guid userGuid { get; set; }
}

public class Absence
{
  public int absenceId { get; set; }
  public Guid applicantId { get; set; }
  public User applicant { get; set; }
  public Guid permitterId{ get; set; }
  public User permitter{ get; set; }
  ...
}

AbsencesConfiguration:
  this.HasRequired(u => u.Applicant).WithMany().HasForeignKey(d => d.ApplicantId);
  this.HasRequired(u => u.Permitter).WithMany().HasForeignKey(d => d.PermitterId);

I’d like a Fluent API mapping between the two classes, but it gives this error message:

Blockquote\tSystem.Data.Entity.Edm.EdmAssociationConstraint: : The types of all properties in the Dependent Role of a referential constraint must be the same as the corresponding property types in the Principal Role. The type of property ‘ApplicantId’ on entity ‘Absences’ does not match the type of property ‘UserId’ on entity ‘User’ in the referential constraint ‘Absences_Applicant’.

I think this is because EF try to join the two tables with the UserId of the User entity and not with UserGuid column. I thought I would make these two columns of Absence entity unique, but how I can map them together?

Thanks in advance.

  • 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-10T20:26:40+00:00Added an answer on June 10, 2026 at 8:26 pm

    The problem is your User primary key is an int, but your foreign key is a Guid.

    You need to alter either your User class to have a guid for userId:

      public Guid userId { get; set; }
    

    or, update your Absence class to use an int:

     public int applicantId { get; set; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following two entities public class User { public int UserId { get;
I have two entities, defined as following public class Corporation { public int Id{get;set;}
I have two entities: public class Parent() { public ICollection<Child> Children { get; set;
I have following two entities public class User { [Key] public int Id {
I have two simplest of Entities, similar to: public class User { int id;
My application has the following entities: public class User { public virtual int UserID
I have two entities like this: public class Service { public virtual int ServiceId
I have the following entities: @Entity public class Owner{ @Id @Column(name = OWNER_ID) @OneToMany()
I have two entities: Recipe and Ingredient. Entites: public class Ingredient { public int
Yo i have the following nhibernate class: public class User { public virtual int

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.