ASP.NET Core sample app illustrating how to use Entity Framework Core together with Steeltoe MySQL Connector for connecting to a MySQL service on CloudFoundry.
There is also an additional sample that illustrates how to use a MySqlConnection
to issue commands to the bound database.
- Installed .NET Core SDK
- Started MySQL docker container
- Installed CloudFoundry (optionally with Windows support)
You must first create an instance of the MySQL service in an org/space.
cf target -o your-org -s your-space
cf create-service p.mysql db-small myMySqlService
cf target -o your-org -s your-space
cd samples/Connectors/src/MySqlEFCore
- Push the app
- When using Windows containers:
- Publish app to a local directory, specifying the runtime:
dotnet restore --configfile nuget.config
dotnet publish -r win-x64 --self-contained
- Push the app using the appropriate manifest:
cf push -f manifest-windows.yml -p bin/Debug/net6.0/win-x64/publish
- Publish app to a local directory, specifying the runtime:
- Otherwise:
- Push the app using the appropriate manifest:
cf push -f manifest.yml
- Push the app using the appropriate manifest:
- When using Windows containers:
Note: The provided manifest will create an app named
mysqlefcore-connector
and attempt to bind the app to MySQL servicemyMySqlService
.
To see the logs as you startup and use the app: cf logs mysqlefcore-connector
On a Windows cell, you should see something like this during startup:
2016-07-01T07:27:49.73-0600 [CELL/0] OUT Creating container
2016-07-01T07:27:51.11-0600 [CELL/0] OUT Successfully created container
2016-07-01T07:27:57.73-0600 [APP/0] OUT Hosting environment: development
2016-07-01T07:27:57.73-0600 [APP/0] OUT Content root path: /home/vcap/app
2016-07-01T07:27:57.73-0600 [APP/0] OUT Now listening on: http://*:8080
2016-07-01T07:27:57.73-0600 [APP/0] OUT Application started. Press Ctrl+C to shut down.
This sample will be available at http://mysqlefcore-connector.[your-cf-apps-domain]/.
Upon startup, the app inserts a couple of rows into the bound MySQL database. They are displayed on the home page.