Entity Framework Code First Demo - Gym Members and Classes
Gym Members
Loading members...
The Azure SQL DB is free-tier and so likely needs "waking-up".
It may take a moment to load the data...
https://gym-membership-webapp.azurewebsites.net/
This is a C# MVC project that creates a SQL Database via Code First EntityFramework Database Migration, populates it and renders its data.
It also demonstrates deployment to Azure via Infrastructure as Code (IaC) using Terraform
Code First EntityFramework Database Migration
- GymMember and ClassSession Data Models are defined.
- The DbContext defines a many-to-many relationship for: A GymMember may attend many ClassSession
-
Running the EntityFrameworkDatabaseMigration creates:
- Database GymMembership
- Database tables GymMember and ClassSession
- The implied many-to-many joining table GymMemberClassSession
- Test data, incuding a GymMember (Alice Johnson) attending several ClassSession (Morning Yoga & HIIT Blast)
Terraform Deployment to Azure
See Terraform configuration file at: https://github.com/wizzard262/EntityFrameworkDotNetCoreMvcCodeFirstSqlGymMembership/tree/main/GymMembers/infra
- Uses the existing Resource Group ResourceGroup1
-
Creates a new App Service Plan (it could not use any existing plan): asp-gym-membership-b1
N.B. Terraform cannot create Free-Tier App Service Plan. This was downgradable to Free via Azure Portal
-
Creates a new Azure SQL Database: GymMembership on an existing Azure Sql Server: wizzard262.database.windows.net
N.B. Terraform cannot create Free-Tier DB. This had to be added via Azure Portal
- Creates a new Azure App Service (Web App) gym-membership-webapp at:https://gym-membership-webapp.azurewebsites.net/
- Injects a ConnectionString into the App Service named: "DefaultConnection" pointing at the new Azure SQL Database: GymMembership
- Sets application settings for the Web App: ASPNETCORE_ENVIRONMENT = "Development"
Azure DevOps Deployment
Terraform creates Resources but a deployment Pipeline is still needed to deploy the resources: