When I use ASP.NET Identity first code approach, I want to generate columns in AspNetUsers table in my own way. I don't need to have stored multiple columns with null values. I just need columns Id, SecurityStamp and UserName. Only post, that I've found is here: AspNet Identity 2.0 Email and UserName duplication , but it is still unsloved (due to error in Santosh comment).
So can anybody tell my how to solve this?
EDIT: Is it even possible to delete some of these columns/properties?
Thanks
The short answer is no, not without rolling your own implementation. Or you can wait for them to open source asp.net identity on codeplex. Who knows how long that will take.
The default implementation includes all of those unused columns (see below).
Actually you can, just configure your entity on
OnModelCreating
of your context class.Or if your application has a separate file for each configuration (wich is what i recommend), you can do like this:
I know this might not be completely related, but if you simply want to exclude columns in JSON responses all you have to do is place [JsonIgnore] above the property. I use Entity so by default the (encrypted) password is included in the model. Even if the password is encrypted you still don't want the end-user to get it. One way to maintain access to that property without including it in a response is shown below.
In the below example the Password field would be removed from the Json response because we added [JsonIgnore] to the model.
Here is a sample JSON response.
Actually you can ignore the fields, just you need to configure your entity OnModelCreating within your context Class as: