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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:43:46+00:00 2026-05-26T17:43:46+00:00

With the following database schema: User: UserID (primary key) UserInfo: UserInfoID (primary key), UserID

  • 0

With the following database schema:

User: UserID (primary key)
UserInfo: UserInfoID (primary key), UserID (foreignKey), [Other columns with UserInfo data]

User and UserInfo have a 1-1 relationship. I want to map this schema to the following POCOs:

public class User
{ 
   [Key]
   public int UserID {get;set;}

   public virtual UserInfo userinfo {get;set;}
}
public class UserInfo
{
  [Key]
  public int UserInfoID {get;set;}

  public int UserID {get;set;}

  [ForeignKey("UserID")]
  public virtual User User {get; set;}

  ... Other properties of UserInfo...
}

Basically I want to be able to load a Users object, and have the related UserInfo object present as well. This seems like a simple task, but I have not been able to find the right combination of attributes and/or fluent API to accomplish this.

EDIT: I have found that making the UserInfo property in Users an ICollection, then everything is wired up properly. So my question now is, is there a way to avoid using an ICollection, as I know that a User will have either 1 or 0 associated UserInfo records.

  • 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-26T17:43:46+00:00Added an answer on May 26, 2026 at 5:43 pm

    For one to one scenarios you have to use the same property as key and fk on both entities.
    Try using the UserId property as the Id of UserInfo entity and then like the Fk to the User property.

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

Sidebar

Related Questions

I have a database schema that is similar to the following: | User |
I have no control over database schema and have the following (simplified) table structure:
I have a database where I store objects. I have the following (simplified) schema
I have the following schema: Database: test. Table: per_login_user, Field: username (PK), password Database:
I have a problem creating a database schema for the following scenario: (I’m not
I have been using the following SQL to create a user, login and database.
I have the following database schema: table courses: id tutor_id title table course_categories: id
I have a MySQL innodb database at 1.9GB, showed by following command. SELECT table_schema
I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20),
Let's say I have the following database table: record_id | record_date | record_value -----------+-------------+--------------

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.