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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:52:13+00:00 2026-05-25T19:52:13+00:00

I have the following ERD and want to convert it EF 4.1 Code First

  • 0

I have the following ERD and want to convert it EF 4.1 Code First classes. For the sake of simplicity, I will concentrate on the first two Entities only.

Quotes Website ERD

Author > Quote.

Which is the correct way of having my code for the Entities, this:

public class Quote
{
    public int Id { get; set; }
    [Required, MaxLength(500)]
    public string Body { get; set; }
    public int Likes { get; set; }
    [Required]
    public bool isApproved { get; set; }
    [Required]
    public DateTime CreatedOn { get; set; }
    public int AuthorId { get; set; }
    public int LanguageId { get; set; }
    public virtual ICollection<Tag> Tags { get; set; }
}

public class Author
{
    public int Id { get; set; }
    [Required, MaxLength(30), MinLength(2)]
    public string FirstName { get; set; }
    [Required, MaxLength(30), MinLength(2)]
    public string LastName { get; set; }
    [Required]
    public DateTime DOB { get; set; }
    public DateTime DOD { get; set; }
    [Required, MaxLength(60), MinLength(2)]
    public string Occupation { get; set; }
    [Required, MaxLength(170), MinLength(5)]
    public string WikiLink { get; set; }
    public byte[] Image { get; set; }
    [Required]
    public bool isApproved { get; set; }
    [Required]
    public DateTime CreatedOn { get; set; }
    public virtual ICollection<Quote> Quotes { get; set; }
}

Where I have given each Quote a property of type Integer signifying the IDs of the Author and Language or this:

public class Quote
{
    public int Id { get; set; }
    [Required, MaxLength(500)]
    public string Body { get; set; }
    public int Likes { get; set; }
    [Required]
    public bool isApproved { get; set; }
    [Required]
    public DateTime CreatedOn { get; set; }
    public Author Author { get; set; }
    public Language Language { get; set; }
    public virtual ICollection<Tag> Tags { get; set; }
}

public class Author
{
    public int Id { get; set; }
    [Required, MaxLength(30), MinLength(2)]
    public string FirstName { get; set; }
    [Required, MaxLength(30), MinLength(2)]
    public string LastName { get; set; }
    [Required]
    public DateTime DOB { get; set; }
    public DateTime DOD { get; set; }
    [Required, MaxLength(60), MinLength(2)]
    public string Occupation { get; set; }
    [Required, MaxLength(170), MinLength(5)]
    public string WikiLink { get; set; }
    public byte[] Image { get; set; }
    [Required]
    public bool isApproved { get; set; }
    [Required]
    public DateTime CreatedOn { get; set; }
    public virtual ICollection<Quote> Quotes { get; set; }
}

Where each Quote has a property of Type Author and one of type Language.

  • 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-25T19:52:14+00:00Added an answer on May 25, 2026 at 7:52 pm

    The first example is rare. You are exposing foreign properties without using navigation properties = you are exposing database specific features but not using object oriented features.

    The second example is common and there is even third possible way where your Quote entity will have both FKs and navigation properties. That will make difference between independent and foreign key associations.

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

Sidebar

Related Questions

I have following code: <div class='parent'> <div class='left-child'></div> <div class=right-child></div> </div> What I want
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
I have following classes. class A { public: void fun(); } class B: public
The following screenshot is ERD for one application or one business. If you have
Have following listener for keyboard ArrowDown event(it's key code is 40 ): window.onload =
Have following strange issue, have 7 lines (same classes) but after 2 lines it's
I have following code that creates Linq query. I've never used Linq until today
I have following json data which I want to pass it to server using
I have following code in C# PasswordDeriveBytes DerivedPassword = new PasswordDeriveBytes(Password, SaltValueBytes, HashAlgorithm, PasswordIterations);

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.