I am a beginner and this is my first project with users.
When I look in the IdentityModels.cs
class I find this code.
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
What is the DefaultConnection
?
Because I can create a user now just fine, without having done anything to any code, but where do my users go?
And when I put my site live, will it be okay, can I just leave all the Identity related code be?
Or should I make it so that it goes into the database I am currently using?
If so, how do I do that?
All other tips regarding Identity and users are also very welcome.
Thank you.
答案 0 :(得分:4)
The DefaultConnection connection string that you are referring to is one that is used as a default by Entity Framework and if you haven't set it since creating the application, it's going to point to a LocalDB instance on your machine.
If you look under the <connectionStrings>
section of your web.config
file, you should see the name of the file that the actual database is stored in (it should be an *.mdf file and you should also see the name of the database) and you should be able to open it using any SQL Server database tool (or some editions of Visual Studio).
If you opened the database up, you should be able to see your actual users and other Identity information / tables :
It's unlikely that you would want to use this same approach when deploying an actual application, so you would just need to change your connection string to target your production database prior to deploying your application.