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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:54:13+00:00 2026-06-13T07:54:13+00:00

I’ve started learning MVC3 development and have hit a bit of a stumbling block.

  • 0

I’ve started learning MVC3 development and have hit a bit of a stumbling block. In my project I’ve moved the default aspnet_ membership tables into a separate SQL Server 2008 Express database. I then added my own tables to hold extra profile data. I’d like to now build a view that will list usernames (from aspnet_Users), email addresses (from aspnet_Membership), First and Last Name (from custom built table UserDetails with userid as PK and FK to aspnet_Users) and the role of users (aspnet_UsersInRoles and aspnet_Roles).

So far to read and write from my database I’ve built models for each of my custom built tables with a dbcontext class:

    public class UserDetail
{

    [Key]
    public Guid UserId { get; set; }

    public string FirstName { get; set; }

    public string LastName { get; set; }

    public string Address { get; set; }

    public string City { get; set; }

    public string State { get; set; }

    public string Zip { get; set; }

    public string Phone { get; set; }

    public DateTime DateUpdated { get; set; }
}

public class UserLinkToken
{
    [Key]
    public Guid UserId { get; set; }

    public string LinkToken { get; set; }

    public DateTime DateUpdated { get; set; }
}

public class ProShotDB : DbContext
{
    public DbSet<UserDetail> UserDetails { get; set; }
    public DbSet<UserLinkToken> UserLinkTokens { get; set; }
}

I’ve had to name my tables “UserDetails” and “UserLinkTokens” for my app to write and update my database, when the names of models and dbcontext didn’t match my database and table names the app would end up creating another database with tables and write the data there.

From what I can tell to send an object to view with properties from aspnet_ tables and properties from my custom tables I will want to build a ModelView. After reading through lots of modelview examples I’m still not clear on how it should look for my app.

Could someone give me an example of a modelview that I could use to display a list of data rows and update all the respective table columns referenced in the modelview given a userid?

For the example lets say I just wanted a view of all the FirstNames (UserDetails table) and their corresponding Emails (aspnet_Membership).

My ultimate goal is a view that will display the users with their assigned roles. Each user listed will have a link that will lead to a controller that will assign them as administrator if they are not currently of that role or remove the administrator role if they are currently an administrator.

Sorry if this type of question has been answered before in other questions. I’ve read quite a few of them and feel like they probably should have answered my question but none seemed to quite match. Most likely my confusion stems from not fully understanding how my app is making the connections to my database. I sort of understand that my models represent a row of data for a table and the dbcontext takes a set of these data row models and connects it to the table in the database (dbset<(datarow/model object)> (table of datarows / set of model objects)). Since I don’t see a dbcontext class for the aspnet_ tables/model objects I don’t have a good concept of how data in those tables are retrieved, updated or written.

Thanks for any help clearing up my ignorance on how this works or giving me a simple example of how to accomplish what I need.

  • 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-13T07:54:14+00:00Added an answer on June 13, 2026 at 7:54 am

    First, it’s called a View Model, not a ModelView. A View Model is simply a class that is customized for the purposes of a view. It typically contains only the data needed for that view, and contains things like Data Annotations to deal with validation and presentation.

    Thus, you just create a model with all the data you want displayed in your view. That’s all there is to building a view model.

    So your view model would simply be

    public class MyViewModel {
        public string FirstName {get;set;}
        public string Email {get;set;}        
    }
    

    Then in your view, you just do something like this:

    @model MyViewModel
    
    @using(Html.BeginForm()) {
        @Html.EditorForModel()
        <input type="submit" />
    }
    

    In your controller (or better yet, in a business layer) you would simply do a query to retrieve the users names and emails, then copy the values from your query results into the view model.

    You do the reverse when you update the data. This is really too large a concept though to discuss in a post like this. You should really look at example code, such as MVC Music Store, or Nerd Dinner.

    The important thing to keep in mind. Membership is a completely separate system from your other tables. You must retrieve them separately, and update them separately. Use the Membership API to update the members email or other details, and use your own tables to update your data.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.