Skip to content

Commit 1c4ce83

Browse files
authored
feat: Add SDK templates for simpler adoption - dotnet new efcptbuild (#33)
1 parent 98bd61a commit 1c4ce83

24 files changed

Lines changed: 2199 additions & 122 deletions

JD.Efcpt.Build.sln

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio Version 17
33
VisualStudioVersion = 17.0.31903.59
44
MinimumVisualStudioVersion = 10.0.40219.1
@@ -21,31 +21,97 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
2121
README.md = README.md
2222
EndProjectSection
2323
EndProject
24+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
25+
EndProject
26+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JD.Efcpt.Build.Templates", "src\JD.Efcpt.Build.Templates\JD.Efcpt.Build.Templates.csproj", "{7F8EBC22-0059-4547-9D26-2B498DB17BBD}"
27+
EndProject
2428
Global
2529
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2630
Debug|Any CPU = Debug|Any CPU
31+
Debug|x64 = Debug|x64
32+
Debug|x86 = Debug|x86
2733
Release|Any CPU = Release|Any CPU
34+
Release|x64 = Release|x64
35+
Release|x86 = Release|x86
2836
EndGlobalSection
2937
GlobalSection(ProjectConfigurationPlatforms) = postSolution
3038
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3139
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Debug|x64.ActiveCfg = Debug|Any CPU
41+
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Debug|x64.Build.0 = Debug|Any CPU
42+
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Debug|x86.ActiveCfg = Debug|Any CPU
43+
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Debug|x86.Build.0 = Debug|Any CPU
3244
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
3345
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Release|Any CPU.Build.0 = Release|Any CPU
46+
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Release|x64.ActiveCfg = Release|Any CPU
47+
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Release|x64.Build.0 = Release|Any CPU
48+
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Release|x86.ActiveCfg = Release|Any CPU
49+
{B6A4F1D0-2B64-4D7B-8D30-2B1C4A3C2E7D}.Release|x86.Build.0 = Release|Any CPU
3450
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3551
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
52+
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Debug|x64.ActiveCfg = Debug|Any CPU
53+
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Debug|x64.Build.0 = Debug|Any CPU
54+
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Debug|x86.ActiveCfg = Debug|Any CPU
55+
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Debug|x86.Build.0 = Debug|Any CPU
3656
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
3757
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Release|Any CPU.Build.0 = Release|Any CPU
58+
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Release|x64.ActiveCfg = Release|Any CPU
59+
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Release|x64.Build.0 = Release|Any CPU
60+
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Release|x86.ActiveCfg = Release|Any CPU
61+
{F4AFEA2B-2B32-4C62-8D6B-9B7DB7E2A1AE}.Release|x86.Build.0 = Release|Any CPU
3862
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3963
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Debug|x64.ActiveCfg = Debug|Any CPU
65+
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Debug|x64.Build.0 = Debug|Any CPU
66+
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Debug|x86.ActiveCfg = Debug|Any CPU
67+
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Debug|x86.Build.0 = Debug|Any CPU
4068
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
4169
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Release|Any CPU.Build.0 = Release|Any CPU
70+
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Release|x64.ActiveCfg = Release|Any CPU
71+
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Release|x64.Build.0 = Release|Any CPU
72+
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Release|x86.ActiveCfg = Release|Any CPU
73+
{0E3C0266-4B23-4F2C-8BA9-AE26EF9C98FE}.Release|x86.Build.0 = Release|Any CPU
4274
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4375
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
76+
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Debug|x64.ActiveCfg = Debug|Any CPU
77+
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Debug|x64.Build.0 = Debug|Any CPU
78+
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Debug|x86.ActiveCfg = Debug|Any CPU
79+
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Debug|x86.Build.0 = Debug|Any CPU
4480
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
4581
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Release|Any CPU.Build.0 = Release|Any CPU
82+
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Release|x64.ActiveCfg = Release|Any CPU
83+
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Release|x64.Build.0 = Release|Any CPU
84+
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Release|x86.ActiveCfg = Release|Any CPU
85+
{A8E5F3D1-4C82-4E9F-9B3A-7D6E8F2B1C9D}.Release|x86.Build.0 = Release|Any CPU
4686
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4787
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
88+
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Debug|x64.ActiveCfg = Debug|Any CPU
89+
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Debug|x64.Build.0 = Debug|Any CPU
90+
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Debug|x86.ActiveCfg = Debug|Any CPU
91+
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Debug|x86.Build.0 = Debug|Any CPU
4892
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
4993
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Release|Any CPU.Build.0 = Release|Any CPU
94+
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Release|x64.ActiveCfg = Release|Any CPU
95+
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Release|x64.Build.0 = Release|Any CPU
96+
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Release|x86.ActiveCfg = Release|Any CPU
97+
{C7D8E9F0-1A2B-3C4D-5E6F-708192A3B4C5}.Release|x86.Build.0 = Release|Any CPU
98+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
99+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
100+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Debug|x64.ActiveCfg = Debug|Any CPU
101+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Debug|x64.Build.0 = Debug|Any CPU
102+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Debug|x86.ActiveCfg = Debug|Any CPU
103+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Debug|x86.Build.0 = Debug|Any CPU
104+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
105+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Release|Any CPU.Build.0 = Release|Any CPU
106+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Release|x64.ActiveCfg = Release|Any CPU
107+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Release|x64.Build.0 = Release|Any CPU
108+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Release|x86.ActiveCfg = Release|Any CPU
109+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD}.Release|x86.Build.0 = Release|Any CPU
110+
EndGlobalSection
111+
GlobalSection(SolutionProperties) = preSolution
112+
HideSolutionNode = FALSE
113+
EndGlobalSection
114+
GlobalSection(NestedProjects) = preSolution
115+
{7F8EBC22-0059-4547-9D26-2B498DB17BBD} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
50116
EndGlobalSection
51117
EndGlobal

QUICKSTART.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
## Installation
44

5+
### Option 0: Use Template (Easiest!)
6+
```bash
7+
# Install template (one-time)
8+
dotnet new install JD.Efcpt.Build.Templates
9+
10+
# Create new SDK project with specific name
11+
dotnet new efcptbuild --name MyDataProject
12+
cd MyDataProject
13+
dotnet build
14+
15+
# Or create in current directory (uses directory name)
16+
mkdir MyDataProject
17+
cd MyDataProject
18+
dotnet new efcptbuild
19+
dotnet build
20+
```
21+
22+
The template creates a project using JD.Efcpt.Sdk for the simplest setup.
23+
524
### Option 1: Quick Start (Global Tool)
625
```bash
726
dotnet add package JD.Efcpt.Build

README.md

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,28 @@ Automate database-first EF Core model generation as part of your build pipeline.
1515

1616
Choose your integration approach:
1717

18-
### Option A: SDK Approach (Recommended for new projects)
18+
### Option A: Use Project Template (Easiest!)
19+
20+
Create a new SDK-based project with the template:
21+
22+
```bash
23+
# Install the template package (one-time setup)
24+
dotnet new install JD.Efcpt.Build.Templates
25+
26+
# Create a new EF Core Power Tools SDK project with a specific name
27+
dotnet new efcptbuild --name MyEfCoreProject
28+
29+
# Or create a project using the current directory name
30+
mkdir MyEfCoreProject
31+
cd MyEfCoreProject
32+
dotnet new efcptbuild
33+
```
34+
35+
Or use Visual Studio: **File > New > Project** and search for **"EF Core Power Tools SDK Project"**
36+
37+
The template creates a project using `JD.Efcpt.Sdk` for the simplest, cleanest setup.
38+
39+
### Option B: SDK Approach (Recommended for new projects)
1940

2041
Use the SDK in your project file:
2142

@@ -28,7 +49,7 @@ Use the SDK in your project file:
2849
</Project>
2950
```
3051

31-
### Option B: PackageReference Approach
52+
### Option C: PackageReference Approach
3253

3354
**Step 1:** Add the NuGet package to your application project / class library:
3455

@@ -53,6 +74,18 @@ dotnet tool install --global ErikEJ.EFCorePowerTools.Cli --version "9.*"
5374

5475
---
5576

77+
## 📦 Available Packages
78+
79+
This project provides three NuGet packages:
80+
81+
| Package | Purpose | Usage |
82+
|---------|---------|-------|
83+
| **[JD.Efcpt.Build](https://www.nuget.org/packages/JD.Efcpt.Build/)** | Main package for MSBuild integration | Add as `PackageReference` to existing projects |
84+
| **[JD.Efcpt.Sdk](https://www.nuget.org/packages/JD.Efcpt.Sdk/)** | SDK package for cleanest setup | Use as project SDK: `<Project Sdk="JD.Efcpt.Sdk">` |
85+
| **[JD.Efcpt.Build.Templates](https://www.nuget.org/packages/JD.Efcpt.Build.Templates/)** | Project templates for `dotnet new` | Install once: `dotnet new install JD.Efcpt.Build.Templates` <br/> Creates SDK-based projects |
86+
87+
---
88+
5689
## 📋 Table of Contents
5790

5891
- [Overview](#-overview)
@@ -173,7 +206,29 @@ See the [SDK documentation](docs/user-guide/sdk.md) for detailed guidance.
173206
- **[MSBuild.Sdk.SqlProj](https://github.com/rr-wfm/MSBuild.Sdk.SqlProj)** - Community SDK for SQL Projects (uses `.csproj` or `.fsproj` extension), cross-platform
174207
- **Traditional SQL Projects** - Legacy `.sqlproj` format, requires Windows/Visual Studio with SQL Server Data Tools
175208

176-
### Step 1: Install the Package
209+
### Quick Start with Templates (Recommended)
210+
211+
The easiest way to get started is using the project template:
212+
213+
```bash
214+
# Install the template package (one-time)
215+
dotnet new install JD.Efcpt.Build.Templates
216+
217+
# Create a new project
218+
dotnet new efcptbuild --name MyDataProject
219+
```
220+
221+
This creates a fully configured SDK project with:
222+
- JD.Efcpt.Sdk as the project SDK (cleanest setup)
223+
- EF Core dependencies
224+
- Sample `efcpt-config.json` with best practices
225+
- Helpful README with next steps
226+
227+
**Visual Studio users:** After installing the templates, you can create new projects via **File > New > Project** and search for **"EF Core Power Tools SDK Project"**.
228+
229+
### Manual Installation
230+
231+
#### Step 1: Install the Package
177232

178233
Add to your application project (`.csproj`):
179234

@@ -191,7 +246,7 @@ dotnet add package JD.Efcpt.Build
191246
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
192247
```
193248

194-
### Step 2: Install EF Core Power Tools CLI
249+
#### Step 2: Install EF Core Power Tools CLI
195250

196251
**Option A: Global Tool (Quick Start)**
197252

samples/template-usage/README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Template Usage Sample
2+
3+
This directory demonstrates how to use the JD.Efcpt.Build.Templates package to create new SDK-based projects.
4+
5+
## Installation
6+
7+
First, install the templates package:
8+
9+
```bash
10+
dotnet new install JD.Efcpt.Build.Templates
11+
```
12+
13+
## Usage
14+
15+
### Command Line
16+
17+
Create a new EF Core Power Tools SDK project:
18+
19+
```bash
20+
dotnet new efcptbuild --name MyDataProject
21+
```
22+
23+
Or create a project using the current folder name:
24+
25+
```bash
26+
mkdir MyDataProject
27+
cd MyDataProject
28+
dotnet new efcptbuild
29+
```
30+
31+
This creates a new project with:
32+
- JD.Efcpt.Sdk as the project SDK
33+
- EF Core dependencies
34+
- Sample efcpt-config.json with best practices
35+
- README with next steps
36+
37+
### Visual Studio
38+
39+
1. Open Visual Studio
40+
2. Go to **File > New > Project**
41+
3. Search for **"EF Core Power Tools SDK Project"**
42+
4. Select the template and configure your project name and location
43+
5. Click **Create**
44+
45+
## Template Features
46+
47+
The template creates a project with:
48+
49+
-**JD.Efcpt.Sdk** as the project SDK for cleanest setup
50+
-**Entity Framework Core** dependencies (SQL Server provider)
51+
-**Sample configuration** (`efcpt-config.json`) with sensible defaults
52+
-**Nullable reference types** enabled
53+
-**Instructions** for adding a database project reference
54+
55+
## Next Steps
56+
57+
After creating a project from the template:
58+
59+
1. **Add a database project reference** to your `.csproj`:
60+
61+
```xml
62+
<ItemGroup>
63+
<ProjectReference Include="..\YourDatabase\YourDatabase.sqlproj">
64+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
65+
<OutputItemType>None</OutputItemType>
66+
</ProjectReference>
67+
</ItemGroup>
68+
```
69+
70+
2. **Customize** `efcpt-config.json` for your needs (namespaces, schemas, etc.)
71+
72+
3. **Build** your project:
73+
74+
```bash
75+
dotnet build
76+
```
77+
78+
Generated models will appear in `obj/efcpt/Generated/`!
79+
80+
## Template Options
81+
82+
The template supports the following options:
83+
84+
| Option | Description | Default |
85+
|--------|-------------|---------|
86+
| `--name` | Project name (optional) | Current directory name |
87+
| `--Framework` | Target framework (net8.0, net9.0, net10.0) | net8.0 |
88+
89+
**Note:** When `--name` is not specified, the template uses the current directory name as the project name.
90+
91+
## Uninstalling
92+
93+
To uninstall the template package:
94+
95+
```bash
96+
dotnet new uninstall JD.Efcpt.Build.Templates
97+
```
98+
99+
## Additional Resources
100+
101+
- [JD.Efcpt.Build Documentation](https://github.com/jerrettdavis/JD.Efcpt.Build)
102+
- [EF Core Power Tools](https://github.com/ErikEJ/EFCorePowerTools)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<PackageType>Template</PackageType>
5+
<PackageId>JD.Efcpt.Build.Templates</PackageId>
6+
<Authors>Jerrett Davis</Authors>
7+
<Company>JDH Productions</Company>
8+
9+
<!-- Package Description -->
10+
<Title>JD.Efcpt.Build Templates</Title>
11+
<Description>Templates for creating projects that use JD.Efcpt.Sdk to automatically generate EF Core models from database projects. Use 'dotnet new efcptbuild' to create a new SDK-based project, or select "EF Core Power Tools SDK Project" in Visual Studio's File > New Project dialog.</Description>
12+
<PackageTags>dotnet-new;templates;efcore;entity-framework;ef-core-power-tools;efcpt;database-first;code-generation;sdk</PackageTags>
13+
<PackageProjectUrl>https://github.com/jerrettdavis/JD.Efcpt.Build</PackageProjectUrl>
14+
<RepositoryUrl>https://github.com/jerrettdavis/JD.Efcpt.Build</RepositoryUrl>
15+
<RepositoryType>git</RepositoryType>
16+
<PackageReadmeFile>README.md</PackageReadmeFile>
17+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
18+
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
19+
20+
<TargetFramework>netstandard2.0</TargetFramework>
21+
<IncludeBuildOutput>false</IncludeBuildOutput>
22+
<NoWarn>$(NoWarn);NU5128</NoWarn>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**" PackagePath="content" />
27+
</ItemGroup>
28+
29+
<!-- Include README -->
30+
<ItemGroup>
31+
<None Include="../../README.md" Pack="true" PackagePath="" />
32+
</ItemGroup>
33+
34+
<ItemGroup>
35+
<Compile Remove="**\*" />
36+
</ItemGroup>
37+
38+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "http://json.schemastore.org/vs-2017.3.host",
3+
"learnMoreLink": "https://github.com/jerrettdavis/JD.Efcpt.Build",
4+
"uiFilters": [ "oneOrMoreProjects" ]
5+
}

0 commit comments

Comments
 (0)