LernenderCorpMicroserviceGeneratorAspNetCore 1.0.2

dotnet new install LernenderCorpMicroserviceGeneratorAspNetCore::1.0.2
This package contains a .NET Template Package you can call from the shell/command line.

LernenderCorp.Microservice.Generator.AspNetCore

Overview

This project is intented to be used by Software Engineers to help facilitate scaffolding of Microservices. The project utilizes 'dotnet ef dbcontext scaffold' to build out models that are reflective on table entities defined within a Microsoft SQL Server Database.

Moreover, using Microsoft's T4 Templating Engine (Microsoft.VisualStudio.TextTemplating) a complete set of Controllers, Services, and Repositories will be automatically created.

Additionally, a Dockerfile was created to help facilitate the need to containerize the Microsoft Project which can subsequently pushed and consumed using AWS Elastic Container Service and/or Kubernetes.

Author

Author: Lovelidge, Shawn

License

This project is licensed with the MIT license.

Prerequisites

The following prerequisites are required to use this package.

  1. Microsoft Windows Pro
  2. Installed .NET SDK 7.0
  3. Install Powershell 7.3 for Windows

Install "LernenderCorpMicroserviceGeneratorAspNetCore" Nuget Package

Using Package Manager; 
Search for PackageId: "LernenderCorpMicroserviceGeneratorAspNetCore" and install this package.

Once installed follow the remaining steps.

1. Verify Installed Template

To see all installed dotnet templates: 
-----------------------------------------------------
c:> dotnet new list

Specific Template (i.e. 'Lernender Corp Microservice Generator AspNetCore'): 
-----------------------------------------------------
C:> dotnet new list | findstr -i Lernender

2. Database

In order for this Microservice Generator to work properly. It must have a valid SQL Server Database. Effectively, the Microservice Generator uses a database as a driver to know how to construct the various layers of the Microservice Api (i..e Controller, Service and Repository).

WARNING:

With out a valid database this Microservice Generator will not work!!! Before moving forward make sure to define a database with valid login administrative credentials. This database and corresponding credentials will be used in the followig steps.

3. Change to Working Directory

Once your template has been installed and verified then change directory to your development folder (example c:\dev)

4. Create MicroService Project

Now you can being using the template to create your first Microservice Project. Execute the dotnet CLI statement listed below.

SYNTAX:
-----------------------------------------------------------------

dotnet new <template shortname> --output <project namespace> --dbContext <dbContext> --sqlDatabase <database name> --sqlServer <IP Address>
Example:
-----------------------------------------------------------------

C:> dotnet new lnmsapi -n {namespace} -o {output directory} --dbContext {dbcontext} --sqlDatabase {database} --sqlServer {server} --passwd {password}

Option Definition
namespace Give a namespace for your microservice. Typically this is your company name followed by the name of your project (i.e. Ln.Microservice)
output directory specify the directory where the project will be created. (note: omit back-slash or forward-slash)
dbcontext Give a name for the dbContext file that will be created (i.e. LnContext)
database Provide the name of the Microsoft SQL Database that will be used to generate the layers of this project
server Provide the server name where the database is stored. This can be an IP address
password Provide the password for connecting to the database.

NOTE:

  • The project should have been created after executing step 3.

  • Change directory to the new project folder.

  • Following the instructions in the next step:

5. Run Powershell Script (RunT4.ps1)

  • Execute Powershell Script (RunT4.ps1)
    [Project Folder] > .\RunT4.ps1

6. Build the Project in Visual Studio 2023

If everything went well your Microservice project has been scaffold out and your entire rest API has been created. Open the solution file in your project folder and take time to examin the code in the Repository, Service, and Controller layers.

WARNING:

The project should work out of the box with one small caveat namely, the Select() calls for all endpoints need to be defined by the developer. Because the domain context of the table entities are not known until runtime it is impossible to accurately generate a fully qualified lambda expression that will select all the rows in a table. Therefore, the developer must supply this code for all Select() methods of each entity within the repository layer.

7. Docker Images

The project comes with a fully qualified dockerfile and the image can built using this file (located at the root of the Project folder).

NOTE:

In order for the docker container to function properly. The developer must replace the setting defined in the 'appsettings.json' located in the ***.Api web project with the settings defined in the 'appsettings.Docker.json' file. This must be done BEFORE the docker image is created.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 232 8/7/2023
1.0.1 209 8/7/2023
1.0.0 158 8/7/2023