EF doesn't support unique columns except keys. If you are using EF Migrations you can force EF to create unique index on UserName
column (in migration code, not by any annotation) but the uniqueness will be enforced only in the database. If you try to save duplicate value you will have to catch exception (constraint violation) fired by the database.