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?
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:

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?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.