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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:42:43+00:00 2026-05-24T07:42:43+00:00

I am working on a mvc3.0 app using EF code first and mvc scaffolding.

  • 0

I am working on a mvc3.0 app using EF code first and mvc scaffolding. I am currently stuck with many to many relation between entities. I have following model.

namespace BigApp.Models
{

#region POCO Objects
public class Group
{
    public int Id { get; set; }
    public string Name { get; set; }        
    public DateTime CreatedOn { get; set; }
    public DateTime UpdatedOn { get; set; }

    public virtual ICollection<Project> Projects { get; set; }
}
public class Project
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Url { get; set; }
    public DateTime CreatedOn { get; set; }
    public DateTime UpdatedOn { get; set; }
    public bool isFeatured { get; set; }
    public bool isDisabled { get; set; }
    public int GroupId { get; set; }
    public virtual Group Group { get; set; }
    public virtual ICollection<Tag> Tags { get; set; }

}
public class Tag
{
    public int Id { get; set; }
    public string Name { get; set; }
    public DateTime CreatedOn { get; set; }
    public DateTime UpdatedOn { get; set; }
    public virtual ICollection<Project> Projects { get; set; }
}
public class Attachment
{
    public int Id { get; set; }

    public DateTime CreatedOn { get; set; }
    public DateTime UpdatedOn { get; set; }

    public int ProjectId { get; set; }
    public virtual Project Project { get; set; }
}

public class BigAppContext : DbContext
{
    // You can add custom code to this file. Changes will not be overwritten.
    // 
    // If you want Entity Framework to drop and regenerate your database
    // automatically whenever you change your model schema, add the following
    // code to the Application_Start method in your Global.asax file.
    // Note: this will destroy and re-create your database with every model change.
    // 
    // System.Data.Entity.Database.SetInitializer(new System.Data.Entity.DropCreateDatabaseIfModelChanges<BigApp.Models.BigAppContext>());

    public DbSet<BigApp.Models.Group> Groups { get; set; }

    public DbSet<BigApp.Models.Project> Projects { get; set; }

    public DbSet<BigApp.Models.Tag> Tags { get; set; }

    public DbSet<BigApp.Models.Attachment> Attachments { get; set; }
}

#endregion

}

You can notice many to many relationship between Tags and projects and one to many relationship between Project and Group. After scaffolding my controllers and views, I have following database created for me based on my model.

https://i.stack.imgur.com/v10oO.jpg

All crud operation are working fine except many to many relation between project and Tags. Check project create interface given below.

https://i.stack.imgur.com/Lzp3j.jpg

All I want is a list box showing all my tags. What changes I have to make. Do I have to update my Project Model? or Introduce a ProjectViewModel that holds all the tags and then passed that to my view?

You can find source code at
github.com/najamsk/BigApp

Thank you. Waiting for responses.

  • 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-24T07:42:44+00:00Added an answer on May 24, 2026 at 7:42 am

    Scott Hanselman’s answer is correct – many-to-many relationships are outside the scope of what scaffolding will handle natively (the reason for this is partly that there are simply too many different common kinds of many-to-many-editing UIs that it’s extremely unlikely we can adequately guess what sort of UI you want).

    Two options:

    1. Use scaffolding as a starting point and, from what you’ve already got, add a multiselect list onto your “Edit Project” screen so users can add/remove tags. This is a manual development step and will require more familiarity with ASP.NET MVC development.
    2. Alternatively, you can create an explicit “link entity”, e.g. called TagAssignment, that has a one-to-many relationship with both Project and Tag (so a Project has many TagAssignments, and a Tag has many TagAssignments). Then scaffolding will be able to generate for you a UI for creating arbitrary numbers of TagAssignments between projects and tags.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an ASP.NET MVC app (using MVC3 RC2). Say I have 2
I have been working on an MVC 3 app. I was using VS 2010's
I am currently working on an ASP.NET MVC 3 app where I have a
I am working on an ASP .NET Mvc 3 App and have installed Ninject.Mvc3
I have a Spring MVC/3.0 app using tiles as it's view, this is working
I have code that works in a .NET 3.5 app that isn't working when
I have just upgraded my mvc2 app to mvc3. And the routelink stopped working.
I have an MVC3 C#.Net web app. In my HTML View, I am using
I have an MVC3 web app to which I want to start using whole
I'm working on an ASP.NET MVC 3 app and it works fine when using

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.