Précis

This will be a short blog post, in part because while I WILL be communicating with this MSSQL Server for Linux Container in Docker, my means of communications will be using Entity Framework Core in my ASP.NET Core application “and” I will be using Code First approach with a ‘endure database’ method call to make sure that if the Database does not exist, that one will be created. This blog post is here mainly for completeness, it will go into how to get the Docker Image needed for this solution, I will illustrate how to get that image down, how to spin up a container based on that image, how the connection is made from the ASP.NET Core App via Entity Framework Core and how I provisioned a database for my solution in that Docker container.

Get the microsoft/mssql-server-linux Base Image

As mentioned in the Volume 1 post you can get access to the Docker Images on Docker Hub, that is where you should go to locate the particular image you need. Below you will see me searching for “Microsoft MSSQL”

as evidenced above, you can see quite a few search results coming back. I prefer to get the one with over 1 Million pulls however Once you have located the image you want, you can learn more about it by clicking on the Details Link.. this will give you a wealth of information including the command to pull it down into your own Docker envionment

Once the Image is down, you can run it with parameters to ensure adherence to the EULA, providing proper username and password and other interactive options. While I indicated above that I will be using EF Core to interact with the MSSQL Linux Docker Container, I also want to be able to see what is going on. There is a variety of tools available to do this but as I am on a Mac, I used the SQL CLI to get SQL Server

Once Installed, you use the commands below to connect to the Docker Container for the SQL instance.

Provisioning the Database I will need for my Xamarin Solution

This database will be provisioned, maintained and opperated from inside the ASP.NET Core App. I will be using a Code First approach with Entity Framework Core. In line 11 below image, this call will ensure that the DbSets are created

The connection is made by the services extension and pointing it to my Docker container hosting the MSSQL-Server-Linux

once the ASP.NET Core Application runs, it checks for the existence of the database and if it is not there, one is created.

Summary

This completes Volume 2. Navigate back to the main Blog for links to other posts.