1

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.

1
  • Look for DefaultConnection in your web.config. If you haven't changed anything it will go into a localdb database stored either in your user profile folder or under App_Data. If you have an application context you can use that connection string or have you application context inherit from IdentityDbContext. Commented Apr 4, 2016 at 16:50

1 Answer 1

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 :

enter image description here

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.