This is the capability to enable the initial creation of the Beef solution and all projects as defined by the solution structure. This leverages the .NET Core templating functionality.
There are two key attributes that drive the template; as well as the underlying code-generation:
- Company - the company and product name (represents namespace and prefixing); e.g.
My.Company
orMicrosoft.Azure
, etc. - AppName - the application / domain name (must be a single unique word); e.g.
App
,Core
,Sales
. There can be multipleAppName
's under aCompany
where supporting multiple business domains within a microservices-based architecture.
These are critical to the naming of the solution and its underlying projects. Once executed the following solution and underlying project structure will be created:
└── <root>
└── Company.AppName.Api # API end-point and operations
└── Company.AppName.Business # Core business logic components
└── Company.AppName.CodeGen # Entity and Reference Data code generation console
└── Company.AppName.Common # Common / shared components
└── Company.AppName.Database # Database and data management console
└── Company.AppName.Test # Unit and intra-integration tests
└── Company.AppName.sln # Solution file that references all above projects
Before the Beef.Template.Solution
template can be used it must be installed from NuGet. The dotnet new install
or dotnet new -i
(deprecated) command is used to perform this:
-- Use the latest published from NuGet...
dotnet new install beef.template.solution --nuget-source https://api.nuget.org/v3/index.json
-- Or alternatively, point to a local folder...
dotnet new install beef.template.solution --nuget-source C:\source\repos\Avanade\Beef\nuget-publish
To create the Solution you must first be in the directory that you intend to create the artefacts within. The beef template requires the company
and appname
attributes as discussed above; it is important that these are entered in your desired casing as they will be used as-is.
Additionally, there is a futher optional datasource
parameter to drive the desired output. This parameter supports the following values:
Parameter | Description |
---|---|
SqlServer |
Microsoft SQL Server with Entity Framework (default). |
SqlServerProcs |
Microsoft SQL Server with Stored Procedures. |
MySQL |
Oracle MySQL with Entity Framework. |
Postgres |
PostgreSQL with Entity Framework. |
Cosmos |
Azure Cosmos DB. |
HttpAgent |
Backend HTTP. |
None |
Empty solution/projects skeleton. |
The dotnet new
command is used to create, e.g.:
dotnet new beef --company My.Company --appname Sales
dotnet new beef --company My.Company --appname Sales --datasource SqlServer
The following will be created:
└── <root>
└── My.Company.Sales.Api # API end-point and operations
└── My.Company.Sales.Business # Core business logic components
└── My.Company.Sales.CodeGen # Entity and Reference Data code generation console
└── My.Company.Sales.Common # Common / shared components
└── My.Company.Sales.Database # Database and data management console
└── My.Company.Sales.Test # Unit and intra-integration tests
└── My.Company.Sales.sln # Solution file that references all above projects
The solution and projects created contain all the requisite .NET Classes and NuGet references to build the solution.
Note: the solution will not intially compile. The code and database generation must first be performed.
To get the solution up and running quickly, an example Person
entity and database table has been preconfigured for code generation. The next sub-sections describe content and how to perform the requisite generation. The entity-driven code-gen step will resolve the aforementioned compilation error.
The Company.AppName.CodeGen
project contains the following:
entity.beef-5.yaml
- a basicPerson
entity example is pre-configured; this can either be extended or replaced.refdata.beef-5.yaml
- a basicGender
reference data entity example is pre-configured; this can either be extended or replaced.
To perform the code generation, first navigate to the directory where the above files reside, then execute the following:
dotnet run all
For more information see: code-generation.
The Company.AppName.Database
project contains the following:
database.beef-5.yaml
- the basicPerson
andGender
Entity Framework or Stored Procedure examples are pre-configured; these can either be extended or replaced.RefData.yaml
- the exampleGender
data has been preconfigured; these can either be extended or replaced.Company.AppName.Database/Migrations
- the example scripts for creating the requite tables forPerson
andGender
; these can either be extended or replaced.
To perform the data generation, first navigate to the directory where the above files reside, then execute the following:
dotnet run all
For more information see: data-generation.
See the following samples for end-to-end usage: