Previous versions of DbSet
Any thoughts on this? I looked in the code and saw that DbSet
@twsouthwick - Do you have specific scenarios where the interface is beneficial over the base type? The issue with interfaces is we either exclude new members or break folks who implement the interface. The base class is also slightly better for folks writing their own test doubles (rather than using a mocking framework) since you only need to implement the methods you actually use.
Closing as we have been using the base type approach in EF6.x for a few releases now and have not heard any feedback on real scenarios where this doesn't work as well.
Feel free to reopen if you want to discuss further :smile:
I am looking fo IDbSet as well . I need to mock a db context and since db contexts are basicly a group of getters and setters on DbSets, I need to be able to mock the DbSets as well.
Trying to do this under .net Core 1.0
There isn't even a public constructor.
No idea how to mock now.
@pgorbas Since DbSet<> is now an abstract base class, you can just use that to mock. You can either derive from it and implement the methods you care about, or use a mocking framework, which will do the same thing, but behind the scenes.
I inherited a project that had IDbSet\
@BrianARice Should be able to use the DbSet class instead.
I liked IDbSet, but I don't really need it anymore. I started coaching the use of query handlers. Makes mocking super easy.
Most helpful comment
@pgorbas Since
DbSet<>is now an abstract base class, you can just use that to mock. You can either derive from it and implement the methods you care about, or use a mocking framework, which will do the same thing, but behind the scenes.