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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:48:33+00:00 2026-05-18T08:48:33+00:00

From the regular aspnet_Users table I have created two sub-tables with one to one

  • 0

From the regular aspnet_Users table I have created two sub-tables with one to one relationship on UserId.

Table UserClient
-UserId int PK
-ClientNumber int

Table UserEmployee
-UserId int PK
-EmployeeNumber int 

I have created a Table per Type model in the edmx and now wish to create the appropriate record in the appropriate sub-table when I create a new aspnet_User record through the membership stored procedures, as shown below:

[HttpPost]
public ActionResult CreateUser(CreateUserModel model)
{
    if (ModelState.IsValid)
    {
    // Attempt to create the user
    MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);

         if (createStatus == MembershipCreateStatus.Success)
             {
             //now that the aspnet_user record is created...

             FilingBizEntities db = new FilingBizEntities();

             //Get the role chosen for the user from selectlist on the CreateUser page
             var thisrole = db.aspnet_Role.Where(rn => rn.RoleId == model.RoleId).FirstOrDefault();

             //Add the user to the role 
             Roles.AddUserToRole(model.UserName, thisrole.RoleName);

             return RedirectToAction("Index", "Users");
             }
             else
             {
                 ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
             }
         }

         ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
         return View(model);
     }

Whether it is of type “UserClient” or “UserEmployee” is dependent on its RoleId, which I currently differentiate when needed by query. Now I wish to extend each type’s properties by having tables.

Let’s say the newly created user is a Client.

How do I insert a record into the UserClient table with it’s aspnet_Users’ UserId and this ClientNumber?

  • 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-18T08:48:33+00:00Added an answer on May 18, 2026 at 8:48 am

    The best way to create a Client for an existing User is to use a stored procedure; not a stored procedure that is wired up to the Client entity through mappings, but a separate one that can be called explicitly from the code.

    Ideally it would be a SP that takes a UserId as a parameter, inserts a new row into the UserClient table using that UserId, and then returns a complete Client object so that it can be used immidiately.

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

Sidebar

Related Questions

I have a array with results from a query from regular tables, for example:
I generally stay away from regular expressions because I seldom find a good use
We are moving from regular 2.0 webforms with no testing to TDD MVC I'm
Can someone provide a regular expression for parsing name/value pairs from a string? The
I am after a regular expression that validates a percentage from 0 100 and
Some Context From Javascript: The Definitive Guide : When regexp is a global regular
How can I create a regular expression that will grab delimited text from a
How do I pull out the filename from a full path using regular expressions
I'm looking for a .NET regular expression extract all the URLs from a webpage
I use RegexBuddy while working with regular expressions. From its library I copied the

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.