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.

NSS
  • 1,835
  • 2
  • 29
  • 66

1 Answers1

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.

Brad Christie
  • 100,477
  • 16
  • 156
  • 200
  • 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](http://stackoverflow.com/questions/21343846/change-the-database-in-which-asp-net-identity-stores-user-data/21344228). – Horizon_Net Jan 31 '14 at 18:50
  • 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 – NSS Jan 31 '14 at 19:53
  • 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**. – Horizon_Net Feb 01 '14 at 00:05