Mocking EF core dbcontext and dbset

前端 未结 4 2087
无人共我
无人共我 2020-12-28 13:29

I am using ASP.NET Core 2.2, EF Core and MOQ. When I run the test I am getting this error:

Message: System.NotSupportedException : Invalid setup on a

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-28 14:02

    The error you're receiving is because you need to declare the Movies property on your dbcontext as Virtual.

    As someone pointed out in the comments, you should use EF's built in memory provider for testing.

提交回复
热议问题