so - I've just started working with ASP .Net Identity framework in my newbie project but I've stumbled upon a logic problem regarding users that I don't know how to resolve, so let me tell what I mean by that.
In my web project I use two databases (both of them uses different db context):
- Business database
- ASP .Net Identity database
Before adding Identity to my project, I've stored all of users informations in my business database (using EntityFramework Core for migrations etc.), their model is like this:
public abstract class User
{
public int Id { get; set; }
[Required(ErrorMessage = "Input login")]
public string Login { get; set; }
[Required(ErrorMessage = "Input password")]
[Display(Name = "Password")]
public string Pswrd { get; set; }
[Required(ErrorMessage = "Input mail")]
[Display(Name = "E-mail")]
public string Email { get; set; }
[Display(Name = "Phone number (optional)")]
[Range(111111111, 999999999)]
public int Phone_nr { get; set; }
}
And then I have two roles for my users which were selected while registering:
public class Poster : User
{
[Display(Name = "Questions asked (total)")]
public int Total_posted { get; set; }
//1 to N
public List<Question> Questions { get; set; }
}
public class Answerer : User
{
[Display(Name = "Answers posted (total)")]
public int Total_answered { get; set; }
//1 to N
public List<Question> Questions { get; set; }
}
Now - when I've added Identity to my project (along with database containing things like users, roles etc.), I figured that I won't need to store informations like id's, passwords, e-mails in my business database but in identity one.
And then comes my problem and my question - should all of user informations be stored in Identity database by customizing IdentityUser class so it will contain some additional properties and just ditch the users table in business db? Because if yes, then how would I include things like foreign keys (or actually - what would be an alternative to them, because I don't know if it will even be possible between two different databases)? Because as it can be seen - my user classes must include references to other class ("Question" class in my case).