I have searched for simple tutorials on how to use Docker with Entity Framework Core with different databases and did try several tutorials and code examples but none of those satisfied me completely. The existing GitHub and Google tutorials are either outdated or not working properly. For that reason, I have written this article. In this article, I shall show you how to create an Entity Framework Core Containerized App with SQL Server 2017 within a Docker container from scratch, and I shall try to use as little code as possible. To make it more interesting, I shall show you how you can enable the Query Store in SQL Server container from the SQL Server Management Studio (SSMS). The SQL Server Query Store allows the analysis of query performance from within the container. In the next article, I shall handle an embedded database like SQLite in the same way. In addition, I shall explain to you how you can open and profile the SQLite database from a Docker container with Db Browser (SQLite).

In my example, I have two Microservices and Products WebAPI. It has one entity “Product”. This service uses SQL Server container as a backend to persist the products. The other service Orders WebAPI (Part II) also has one entity “Order” and it uses the SQLite to persist the orders. The main difference between Product service and the Order service is that the Order service contains an embedded database (in-process database) within the container itself.

I am using one database pro service technique, i.e., we have two databases ( ProductsDb and OrdersDb).

ProductsWebApi contains only the connection information to the database, and in this case, the SQL Server Container. Additionally, it is linked to the SQL Server container as shown in the image -1- below.

OrdersWebApi (Part II) is generating the database when the service startup.



Image -1- Databases in the containers Image -1- Databases in the containers