2

Ok so i know I'm fairly new to C# and MVC but I'm trying to use the code first approach of adding items to a database.

Now I have successfully created new entries to the database but when I go to SQL Server i cannot find the database or tables.

So my question is where is this data being stored as I can't see it in SQL Server like my other databases that I manually created?

My ConnectionString is:

Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-Testing-20140809020449.mdf;Initial Catalog=aspnet-Testing-20140809020449;Integrated Security=True

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
niko619
  • 433
  • 9
  • 20

2 Answers2

4

LocalDb is the new server-less version of SQL Server that has similar features as SQL Express. I would describe it as a just-in-time version of SQL Server that is only running when needed.

In order to connect to it usng SQL Server Management Studio, you need to connect using the following connection string (assming SQL Server Version 11/2014 may change to 12 or higher in future versions):

SMSS LocalDB

Then you'll have access to the database.

enter image description here

Community
  • 1
  • 1
Erik Philips
  • 53,428
  • 11
  • 128
  • 150
  • Ok so the original connection string was auto generated. I have now changed it to Server=myServerAddress;Database=myDataBase;UserId=myUsername;Password=myPassword; and it works. However it has added AspNetUser tables as well?? – niko619 Aug 09 '14 at 14:52
  • When choosing the application type for MVC if you picked an authorization type of *Individual User Accounts* then the template will create by default an Entity Framework context (using the same connection string) and populating the database with tables to store user information using [ASP.Net Identity 1/2](https://identity.codeplex.com/) framework. – Erik Philips Aug 09 '14 at 14:58
  • just for reference: the default instance of LocalDB 2014 is called "mssqllocaldb". – Michael Edenfield Aug 09 '14 at 15:03
  • Oh yeah I have never seen that before. Is it possible to change the authorization type half way through a project? – niko619 Aug 09 '14 at 15:04
  • @user3147812 Not that I am aware of. – Erik Philips Aug 09 '14 at 15:07
3

[project_dir]\App_Data\aspnet-Testing-20140809020449.mdf

romanoza
  • 4,775
  • 3
  • 27
  • 44