---
title: "Comment by Somanath Sutar on \"Creating Worker Service + Entity Framework Core in .NET\" | Hashnode"
description: "How do I write MS unit test for DbHelper.cs? I am unable to mock. In each DbHelper method there is _dbContext = new AppDbContext(GetAllOptions()) and GetAllOpti"
url: "https://hashnode.com/posts/creating-worker-service-entity-framework-core-in-net/621513343b018a8cb17c0b5c/comment/64baea03a8381eef4cb8fcad"
---

[Discussion](https://hashnode.com/posts/creating-worker-service-entity-framework-core-in-net/621513343b018a8cb17c0b5c)

Comment [Creating Worker Service + Entity Framework Core in .NET](https://hashnode.com/posts/creating-worker-service-entity-framework-core-in-net/621513343b018a8cb17c0b5c)

[Somanath Sutar](https://hashnode.com/@somanathsutar)

[Jul 21, 2023](https://hashnode.com/posts/creating-worker-service-entity-framework-core-in-net/621513343b018a8cb17c0b5c/comment/64baea03a8381eef4cb8fcad)

How do I write MS unit test for DbHelper.cs? I am unable to mock. In each DbHelper method there is \_dbContext = new AppDbContext(GetAllOptions()) and GetAllOptions is looking for connection string. So overall it doesn't look right for mocking and creating unit test cases. Any example will help.
