Two databases in my MVC ASP.NET movies tutorial

Hi there,

I am totally new to MVC and am doing the Movies tutorial on the ASP.NET MVC site.

I have been given two connection strings.. essentially adding another connection string to the one that was already in the webconfig <connectionsStrings> section.

The project uses the Entity Framework to create the database in SQLEXPRESS from the model. However, I end up with two databases - one for the security and one for Movies... further I also end up with the Security database under App_data and the other in the data directory within the SQLEXPRESS direcctories.

By the way I also added in the option of "User Instance=true" to try and force it into the local dirctory

My connection strings as given by the tutorial are:

		<add name="ApplicationServices"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />
		<add name="MovieDBContext"
     providerName="System.Data.SqlClient" />

Open in new window

I removed the second connection string all together and it still created a database called MvcMovie.Models.Movie+MovieDBContext in the SQLEXPRESS data directory.

How do I have only one database that sits within the project... what connection string will support that...

It puts the security  e.g Login/user details in another database.....

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are you saying you want to combine the two databases or are you saying you need the Movies database to be in the App_Data folder?

I'm guessing you're looking at the below tutorial:

si2030Author Commented:
Hi nmarun,

Actually I was working my way through this tutorial:

Sorry for not indicating such.

What it did was to create an ASPNET database in the App_Data folder and then I had to create another database which ended up in the data directory in the SQLEXPRESS MSSQL Directory...

What I wanted to know was.. can you combine the two databases and have it reside under theApp_data folder in your project?
Aaah.. now I understand your question.

These are two different databases used for completely different purposes. I strongly recommend against combining them.

You might try the following connection string:

<add name="Northwind"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\Movies.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />

This I think will show the database in your App_Data folder.

Alternatively you might want to use SQL Server CE 4 database. This is a file based SQL database. You can find more information about this here:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.