Unique key constraint RRS feed

  • Question

  • User2090306728 posted

    Ok, so primary keys (a single table field or a combination) uniquely identifies a record in table.

    A foreign key represents the relationship of how one field is connected to a primary field in another database table.

    My question is, how can create two SEPARATE unique keys in one table?

    For example, I've added a username field to the User Identity table so the user can either login using either their username or email address (currently default in ASP.NET Identity)?

    How would I represent the username field? 

    I've read up a little on unique constraints but only seem to be getting results regarding primary keys!

    I'm using Code First Entity Framework so if someone could give me the Data Annotation solution to this, that would be very much preferred, otherwise help of any kind to point me in the right direction would be greatly appreciated.


    Tuesday, November 15, 2016 11:45 PM


All replies