I'm writing a simple asp.net application with the entity framework and mvc.
I started with a template which actually includes a simple account creation and login system. However I wish to store account details in a database.
var user = new ApplicationUser() { UserName = model.UserName };
var result = await UserManager.CreateAsync(user);
if (result.Succeeded)
{
result = await UserManager.AddLoginAsync(user.Id, info.Login);
I want to ask these two things
From what I see, or my guess, you are using ASP.Net MVC 5 and that is the scaffold code.
Can I use the UserManager class to store and manage users in my own database structure? Yes, you can use the UserManager object to store users. First thing you would want to do is open IdentityModels.cs and modify the class to add in any extra fields if needed:
public partial class ApplicationUser : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
//Etc
}
Where is the example (default .net mvc application) storing username / password? Have a look at your web.config. An example of what I have on my dev machine:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebApplication1-20140606091757.mdf;Initial Catalog=aspnet-WebApplication1-20140606091757;Integrated Security=True" providerName="System.Data.SqlClient" />
What this means is that you need to connect to your datasource specified in your web.config. In Visual Studio click on show all files:
Then, double click on the mdf file which will open up the server explorer. Browse to the AspNetUsers table: