Unit testing Entity Framework with Mock IDbSet

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 02:01:09

You shouldn't need to implement the get/set, the following code should be enough to generate the context for you.

public class MockGolfEntities : DbContext, IContext
{
    public MockGolfEntities() {}

    public IDbSet<Golfer> Golfers { get; set;}

}

I've implemeted the code you had in your original post and everything seemed to work well for me - where did you get the source for the InMemoryDbSet? I'm using the NuGet package 1.3, maybe you should try that version?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!