Using Service Connectors with Microsoft SQL
This tutorial takes you through setting up a .NET Core application with the Microsoft SQL service connector.
Note
For more detailed examples, please refer to the SqlServerEFCore project in the Steeltoe Samples Repository.
First, start an MsSQL instance using the Steeltoe dockerfile.
docker run --env ACCEPT_EULA=Y --env SA_PASSWORD=Steeltoe123 --publish 1433:1433 steeltoeoss/mssql
Next, create a .NET Core WebAPI that interacts with MS SQL
Create a new ASP.NET Core WebAPI app with the Steeltoe Initializr
Name the project "MsSqlConnector"
Add the "Microsoft SQL Server" dependency
Click Generate to download a zip containing the new project
Extract the zipped project and open in your IDE of choice
Set the instance address in appsettings.json
{ "sqlserver": { "credentials": { "server": "127.0.0.1", "port": "1433", "username": "sa", "password": "Steeltoe123" } } }
Tip
Looking for additional params to use when connecting? Have a look at the docs
Run the application
dotnet run <PATH_TO>\MsSqlConnector.csproj
Navigate to the endpoint (you may need to change the port number) http://localhost:5000/api/values
Once the app loads in the browser you will see a list of the default sys tables installed with MS SQL. "["spt_fallback_db","spt_fallback_dev","spt_fallback_usg","spt_values", "spt_monitor","MSreplication_options"]"