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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:26:46+00:00 2026-06-10T18:26:46+00:00

I am trying to build a complicated web project that involves 4 websites that

  • 0

I am trying to build a complicated web project that involves 4 websites that all share the same models, database and also use the built-in forms based authentication.

It was previosuly been suggested to me to create a class library which contains the shared elements and then to reference that library in each of my projects. This makes sense to me but I seemed to run into a lot of errors even after getting all the references included. So I basically started from scratch and now I have two regular MVC 4.0 projects under one solution. The first project is working fine. It contains the forms based authenticxation membership controllers and models as well as all my data models and the App_Data folder with the db inside. The web.config file points to the DB and I have absilute no problems testing the Membership featues with the default view and controllers supplied.

I have set a depndency on the second app on the first and referenced the first project as well. This project contains only default HomeController and Views. I get no errors on build. When I go to run the webite and then try to access /Account/LogOff for example, I receive the following error:

Cannot attach the file ‘~\App_Data\Pp.mdf’ as database ‘Pp.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot attach the file ‘~\App_Data\Pp.mdf’ as database ‘Pp.

Source Error:

Line 39: }
Line 40:
Line 41: WebSecurity.InitializeDatabaseConnection(“PpDB”, “UserProfile”, “UserId”, “UserName”, autoCreateTables: true); Line 42: }
Line 43: catch (Exception ex)

Source File: c:\Users\Administrator\Documents\Prp\PpModels\Filters\InitializeSimpleMembershipAttribute.cs Line: 41

I tried playing with the second project’s connection string but I’m really not sure how the paths get resolved using MVC.

Any help and advice would be appreciated. I am pulling my hair out! If you kow f any tutorials that show you how to use multiple projects sharing models and DB’s that would be much appreciated. Thanks!

  • 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-10T18:26:48+00:00Added an answer on June 10, 2026 at 6:26 pm

    The answer is to hard code the full path within the connection string in the second project so that it points to the app_data folder in the first project.

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

Sidebar

Related Questions

I am trying to build a complicated spreadsheet and I need a statement to
I am trying to build a lambda expression that will be combined with others
I am trying to build a simple worker function that takes a config of
Ok SQL and Oracle gurus I have a somewhat complicated query that I'm trying
I'm trying to build some complicated stuff for an C# winform application being build
I'm trying to build a progressbar class that can have an arbitrary number of
Trying to build a somewhat complicated WordPress query. In one query, I'm trying to:
I'm trying to build a game that sends game play data to a rails
I am trying to build a 1.0 version for a web application, and I
We're trying to build up a minorly complicated Zip file in Gradle from multiple

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.