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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:36:19+00:00 2026-06-13T11:36:19+00:00

When creating a new ASP.NET MVC3 application, in the default project there is a

  • 0

When creating a new ASP.NET MVC3 application, in the default project there is a Models folder. This Models folder includes the AccountModels – RegisterModel, LoginModel, etc.

I have a separate project for the DAL – it includes a repository and a service.

Now, I have a method in my service:

TblUser Register(RegisterModel model);

For this to work, I must reference the web project in my data project.

Is this appropriate, or should I include my Models folder in my data project instead?

  • 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-13T11:36:20+00:00Added an answer on June 13, 2026 at 11:36 am

    Your first option is not appropriate. That’s what’s referred to as a circular dependency and it is bad.

    Your second option is better, but still not great. Your model classes will undoubtedly have fields and methods which are applicable to your ui only. Those don’t belong in your data layer any more than your data objects belong in your web tier. That’s an example of coupling – also known as a poor separation of concerns – and it is also bad.

    The best option is to separate out data which is needed by both tiers out into a distinct set of classes (sometimes referred to as dto’s – data transfer objects – or poco’s – plain old class objects). Those classes can reside in your data project or in a project entirely to themselves depending on your needs. If your service resides in a WCF service, these classes will typically be DataContracts. Then, within your MVC project you should have your models, as they are now, but they should contain references to your POCO’s instead of holding any data of their own. So in your specific case you would create a RegistrationInfo class (or whatever you want to call it) in your data project, then add a field of type RegistrationInfo to your model and pass it to your service instead of the entire RegistrationModel.

    EDIT: added an example

    namespace MyProject.Data.Objects {
        public class RegistrationInfo {
    
            [Required]
            public string Username { get; set; }
    
            [Required]
            public string Password { get; set; }
    
            [Required]
            public string Email { get; set; }
    
        }
    }
    
    namespace MyProject.Data {
        public class MyService {
            public TblUser Register(RegistrationInfo info) {
                // .. save to the database ..
            }
        }
    }
    
    namespace MyProject.UI.Models {
        class RegistrationModel {
            public RegistrationInfo Info { get; set; }
    
            /* Fields which the ui needs but the database does not */
            public bool ConfirmPassword { get; set; }
            public bool AllowFreeEmailAddresses { get; set; }
    
            public void Save() {
                new MyProject.Data.MyService().Register(this.Info);
            }
    
            public RegistrationModel() {
                this.Info = new RegistrationInfo();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a new web application using ASP.NET MVC3 Razor and HTML 5.
I'm creating a new project, asp.net mvc3 with Razor, and wanting to turn the
When creating a new ASP.NET AJAX Web Application in Visual Studio 2005, the default
I am thinking about creating my new asp.net mvc web application compatible with native
I'm creating new Site Definitions using this method: http://weblogs.asp.net/paulballard/archive/2007/04/09/creating-a-custom-sharepoint-2007-portal-site-definition-using-the-portalprovisioningprovider-class.aspx and when they get created,
We're creating a new consumer/public-facing ASP.Net web app. There are two concerns: --Use cookie
I have created a new ActionFilter for an ASP.NET MVC application that I'm creating.
I got a problem. When i'm creating the new project in ASP.NET using VS
When creating a new asp.net mvc3 app you get the logon and register form
Upon creating a new ASP.NET MVC 3 Razor site, there are 9 Account\*.cshtml files

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.