Reputation: 403
I am a newbie to .NET web API and struggling with the identity API of it. I created a new project with MVC Web API template and Individual account authentication.
I tried running the project and calling the Register API and it gives me error with creating the .mdf file.
Then I changed the connection string to a connection string from my another project where I followed data first approach to create user modals. This connection string points to a SQL server database.
<add name="myApp" connectionString="metadata=res://*/Models.myAppData.csdl|res://*/Models.myAppData.ssdl|res://*/Models.myAppData.msl;provider=System.Data.SqlClient;provider connection string="data source=User\SQLEXPRESS;initial catalog=myDB;user id=sa;password=xxx;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Now when I call Register API, I get status 200 and if I try to call register API with same username again, it says this users already taken. It doesn't appear in my SQL server db neither there is any .mdf file.
Upvotes: 2
Views: 830
Reputation: 300
It is storing in your SQLEXPRESS that is installed on your machine.Did you get it ?
If you want to quickly look at the tables.You can do it directly in VS 2013.
In VS 2013,(Screen shot 1 below)
For any reason if that does not work, Follow the same steps but choose SQL server Object Explorer (Screen shot 1 below), Using this you should see all the servers installed on your machine you have find the right one
Your Database Name = myDB
user id=sa
password=xxx
If all this does not work, Stop Debugging,Open up your main web.config and backup you connection string and updated below connection string .(This connection string will work for local db version 11 which you should get the latest VS, If not update it with the version of local db you have on your machine.).
Create a folder in the project and rename to App_Data.
Build your application and run it.
Now Stop it and Click on Show all files in Solution Explorer.
You should now see a mydb.mdf file in the App_Data folder in the solution explorer,which is your temporary database. Double click and access it.
if you cannot figure this out in App_data folder, then follow the steps of using SQL Server Object explorer.
<add name="myApp" connectionString="metadata=res://*/Models.myAppData.csdl|res://*/Models.myAppData.ssdl|res://*/Models.myAppData.msl;provider=System.Data.SqlClient;provider connection string="data source=LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\myDB1.mdf;initial catalog=myDB1;user id=sa;password=xxx;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.SqlClient" />
Upvotes: 2