I\'m using the Entity Framework with a large database (made up of more than 200 tables).
Trying to create a generic method that returns the DbSet
I don't know how you have created your model, and thus how your entities look like. But, if it's Code First, the entity classes don't inherit from a common base class, so you cannot add a type constraint to your generic.
I don't recommend using a base class to be able to specify a constraint. It's much better to do it using an interface. An empty interface will allow you to specify a constraint without having to change your classes at all.
So, what you can do is define an interface like this:
public interface IEntity {};
And then:
where IEntity
This is the cleanest way to do it, without any interference to your classes.