1

In my project, my user class is inheriting from IdentityUser, and because i have alot of users and i'm performing alot of queries against the user email (which is an IdentityUser property) i wish to have it indexed.

How can one index properties of IdentityUser?

I was thinkin about overriding the Email property and put the [Index] annotation, but will this breaks something?

Note that my project is based on ASP.NET MVC 6 template, and i'm using Entity framework code-first approach.

6
  • So you are using code-first and entity framework? Commented Jul 4, 2016 at 10:26
  • Yes i do, i have edited my question to include this information, thanks :) Commented Jul 4, 2016 at 10:33
  • Is the email already a primary key for your table in the db? If so, there already is a primary index. Also this might help you stackoverflow.com/questions/22618237/… Commented Jul 4, 2016 at 10:37
  • 1
    In IdentityUser, only the Id is a PrimaryKey, but will overriding the Email property and put the [Index] annotation will break anything? i find this to be a better approach than to edit the migration first schema because i might not always use it or i can accidently drop it, where the [Index] annotation will always be there Commented Jul 4, 2016 at 10:45
  • 1
    Ok, will the Original Email Annotation (which are added in the IdentityUser class such as maximumlength) will be applied in my overiding? Commented Jul 4, 2016 at 14:27

0

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.