0

In my asp.net mvc 3 application, I have a generic Repository. I use the Find method of the DbSet class to find an entity by its Primary Key, like here:

private DbSet<T> _dbSet;

public T FindByID(object id)
{
    return _dbSet.Find(id);
}

Is there any way I can find the entity using the Unique Key as well? I was not able to find the source code for the DbSet class. I would like to extend the DbSet class and add a new method to it for this purpose, if it's possible.

ataravati
  • 8,891
  • 9
  • 57
  • 89

1 Answers1

0

It seems like Entity Framework does not support unique keys, according to this answer:

Alternate/candidate key in ADO.NET data model

Community
  • 1
  • 1
ataravati
  • 8,891
  • 9
  • 57
  • 89