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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:35:14+00:00 2026-05-27T09:35:14+00:00

I am trying to learn mvc – I apologize in advance for all the

  • 0

I am trying to learn mvc – I apologize in advance for all the silly questions. What I’ve done is created an mvc proejct based on an exsiting database, and then i’ve been disecting it to try to understand what’s been created for me, and how to create my own stuff. Unfortunately, because I’m a new stackoverflow user, i can’t post a picture of my project structure.
i have a parent controller and a child controller created using the wizard based on 2 separate tables i have in my model. I want to display both of them in one view – ultimately in a webgrid and be able to change data for any parent item, or child item. You can ignore the CombinedController for now. I’ve been doing some reading and i’ve learned that i should be creating a viewmodel that combines both the parent and child at the model level, and then go from there.

so i created this class:

Imports System.Data.Objects.DataClasses
Public Class ParentAndChild

    Public Property myChildren As IEnumerable(Of Child)
    Public Property myParent as Parent

End Class

I have a few questions:

Question 1
Do i have to add this ParentAndChild entity into the .edmx file in order to create a controller and view for it? I guess what I’m really asking is do i have to create a view in the sql database first, have the entity show up in the .edmx and then create a controller? Or can I just combine the two entities in a class? That’s what i’ve done so far. I don’t have a sql View in my database combining these two tables. The reason why I ask is because when i create my controller, if i want to get all the CRUD for free, i have to create using the Entity Framework. But I don’t know what to specify for the data context.

Question 2
If i want a webgrid to somehow show all my parents and all their children, will the new ParentAndChild class work? I think that will only show the details for One parent and its children. I think i need to create a list of parents.. and then in the parentlist for each parent, add a collection of modules. But i don’t know how to do this..

Question 3
How does the entityframework know which modules to return when i’m using my new class? I don’t define the relationship anywhere… Is it because in the .edmx file, the system knows the relationships between the tables?

  • 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-27T09:35:15+00:00Added an answer on May 27, 2026 at 9:35 am

    If you simply need to access the information of a parent entity and its child entity’s you should be able to send your view the parent entity. A ViewModel is not absolutely necessary for this if Entity Framework knows about the relationship between the two entity’s. If the relationship between the 2 tables exists at the database level then Entity Framework should have modeled it automatically.

    An example of a controller would be:

    public ActionResult Parent(int id)
    {
        var parent = context.Foo.Single(x => x.Id == id);
        return View(parent);        
    }
    

    If you need to create a table of all the child entity’s you could do something like this:

    @foreach(var item in Model.Children)
    {
        <td>@item.Property</td>
        <td>@item.Property2</td>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn ASP.net MVC 2 and I have created the DB
I am trying to learn Microsoft MVC 2, and have in that case found
I am trying to learn asp.net MVC and having an issue to submit a
I'm trying to learn ASP.NET MVC + Entity Framework by developing a small project.
Well I am trying to learn the java MVC pattern, but I can't understand
I'm trying my best to learn MVC and cakePHP and I had a question
I am trying to learn some ASP.NET MVC. Please bear with me but asp.net
I am finally experimenting and trying to learn MVC after years of asp.net. I
I'm trying to learn Spring MVC 3.0 and I made a simple web to
I'm trying to learn ASP.NET MVC, and I want to have menus highlighted on

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.