Background
I have a project written with C# and ASP.NET core (v2.2). This project is connected to a database that holds a table called "AspNetUsers". The building strategy is "Database First".
I'm building the models from the data with this command:
Scaffold-DbContext "...DB-CS..." PROVIDER -Context UsersDB -f -OutputDir Processes\Models
Then it's created for me this mapped class:
public partial class AspNetUsers
{
public AspNetUsers()
{
}
public string Id { get; set; }
public DateTime RegistrationTime { get; set; }
// ...
}
On my website, I'm using the UserManager
class. This class is expecting to get an Object that inherits from the IdentityUser
interface.
The Question:
Is this possible to make my AspNetUsers
class implementing IdentityUser
?
Thanks!
Update #1
Thanks for @Darjan Bogdan answer, I created this new file:
public partial class AspNetUsers : IdentityUser
{
}
and changed my UserManager
to looks like this:
private UserManager<AspNetUsers> UserManager { get; set; }
On first looks, it looks like work. When going deeper to check this - I got many strange errors like :
User security stamp cannot be null.
Although AspNetUsers instance has SecuriyStamp
field (not null).
I checked the AspNetUsers
file (auto-generated) and it seems like some properties are hiding another.
Question: I working in Database first model. So, the AspNetUsers file is auto-generated. How to avoid hiding other properties?