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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:09:44+00:00 2026-06-08T11:09:44+00:00

I am trying to implement code-first approach of entity framework. I have four entities

  • 0

I am trying to implement code-first approach of entity framework. I have four entities UserInfo, Client, Admin and Account. I want relationships as:

  • Each Client has a UserInfo
  • Each Admin has a `UserInfo
  • Each Account is linked with a User(UserInfo)

Assuming these things i wrote the POCO models. With the relationships i want, is it correct ?Am i missing something?

public class UserInfo
    {
        public int UserInfoID { get; set; }
        public Name Name { get; set; }
        public Address Address { get; set; }
        public Contact Contact { get; set; }
    }

public class Admin
    {
        public int AdminID { get; set; }
        public int UserInfoID { get; set; }
        [ForeignKey("UserInfoID")]
        public virtual UserInfo UserInfo { get; set; }
    }

public class Client
    {
        public int ClientID { get; set; }
        public CompanyDetails CompanyDetails { get; set; }
        public int UserInfoID { get; set; }
        [ForeignKey("UserInfoID")]
        public virtual UserInfo UserInfo { get; set; }
    }

 public class Account
    {
        public int AccountID { get; set; }
        [Required, Column("Balance"), Display(Name = "Account Balance")]
        public double Balance { get; set; }
        public int UserInfoID { get; set; }
        [ForeignKey("UserInfoID")]
        public virtual UserInfo UserInfo { get; set; }
    }
  • 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-08T11:09:45+00:00Added an answer on June 8, 2026 at 11:09 am

    What you have appears to be correct based on your requirements however I personally prefer the Entity Framework Model Builder when configuring your entities with Code First.

    Using the model builder means that you don’t have any attributes on your POCO entities which in turn means that you don’t need an EF reference to use the entities.

    Take a look at my article here for some more info on how to use the modelbuilder : http://blog.staticvoid.co.nz/2012/07/entity-framework-navigation-property.html

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

Sidebar

Related Questions

I am trying to implement code to create an account for my app. So
I have tried to implement this scenario . I have created Code First model,
I have just started using EF Code First to implement a simple blog. I
That's my first approach with GD stuff. I'm trying to implement resize and crop
I'm trying to implement my own kind method cache. For that, first I want
I'm getting this error when I'm trying to implement this code. The first code
I have a basic question about implementing a Entity code first one to many
I am trying to implement some code on my web page to auto-scroll after
I'm trying to implement the example code of the following question by using opencv
I am trying to implement a simple code tester : a very basic version

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.