0

I wanted to store change the connection string so that it points to existing database that has all the necessary tables. when searched for "DefaultConnection" i am not able to find that any where in the application, Models folder does not have any of the models related to classes. All i see is the interface definitions is metaData. I can change the connection string value in the web.config to make it work, but now i am kind of intriguing to know how it implemented so that in case i want to customize the logic, where can i find those classes ?

I am using the latest version of WebAPI and using VS 2013.

What is confusing me is where how to modify the classes to implement custom logic, i can't find the model classes related to identity.

1 Answer 1

1

You were right, the web.config is the place to change it. Though can implement another constructor in your ApplicationDbContext which calls the base [IdentityDbContext<TUser>] class' constructor which accepts a nameOrConnectionString. From there it's either specify to use :base("Data Source=...;Initial Catalog=...;...") or use your new overriden constructor.

Also, your user should (by default) be something called ApplicationUser which inherits from the IdentityUser (which is just a dummy class that implement IUser and adds some foreign keys like Claims, Logins and Roles (among others)). So, if you need to customize it you should add your custom logic/properties to that object.

What's important to note is that everything but your context and custom (inherited) version of IdentityUser are within the identity library. So, the only customization you're going to get is from the "ApplicationUser" and "applicationDbContext" on up.

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

3 Comments

If you want to see some short code snippets for the solution @Brad suggested (which is the best way) have a look at this thread.
My problem is i can't find any of those class(i.e ApplicationDbContext) in my project. The only files that i can see are AddExternalLoginBindingModel.cs & AccountViewModels.cs. I can see the AccountController and when i right click & select GoTo Defination it takes me to the embedded metada that has no implementation in it. Not sure if this is setup issue, but my default login functionality is working fine, the problem is with customization since i can't find those files
That's a custom class which does not come out of the box. If you don't have an ApplicationDbContext, create a new class and modify it like mentioned in my other comment. With that you can customize the context in any way you want, but remember that it is import that the custom context has to inherit IdentityDbContext<TUser>.

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.