Skip to content

JerrettDavis/JD.Efcpt.Build

Repository files navigation

JD.Efcpt.Build

NuGet License CI CodeQL codecov

MSBuild integration for EF Core Power Tools CLI

Automate database-first EF Core model generation during dotnet build. Zero manual steps, full CI/CD support, reproducible builds.

Quick Start

Option A: Project Template (Easiest)

dotnet new install JD.Efcpt.Build.Templates
dotnet new efcptbuild --name MyDataProject
dotnet build

Option B: SDK Approach (Recommended)

<Project Sdk="JD.Efcpt.Sdk/1.0.0">
    <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
    </PropertyGroup>
</Project>

Option C: PackageReference

dotnet add package JD.Efcpt.Build
dotnet build

.NET 8-9 users: Install the CLI tool first: dotnet tool install -g ErikEJ.EFCorePowerTools.Cli --version "10.*"

.NET 10+ users: No tool installation needed - uses dnx automatically.

Available Packages

Package Purpose Usage
JD.Efcpt.Build MSBuild integration Add as PackageReference
JD.Efcpt.Sdk SDK package (cleanest setup) Use as project SDK
JD.Efcpt.Build.Templates Project templates dotnet new install

Key Features

  • Automatic generation - DbContext and entities generated during dotnet build
  • Incremental builds - Only regenerates when schema or config changes
  • Dual input modes - Works with SQL Projects (.sqlproj) or live database connections
  • Smart discovery - Auto-finds database projects and configuration files
  • T4 template support - Customize code generation with your own templates
  • Multi-schema support - Generate models across multiple database schemas
  • CI/CD ready - Works everywhere .NET runs (GitHub Actions, Azure DevOps, Docker)
  • Cross-platform SQL Projects - Supports Microsoft.Build.Sql and MSBuild.Sdk.SqlProj

Documentation

Topic Description
Getting Started Installation and first project setup
Using the SDK SDK approach for cleanest project files
Configuration MSBuild properties and JSON config options
Connection String Mode Generate from live databases
T4 Templates Customize code generation
CI/CD Integration GitHub Actions, Azure DevOps, Docker
Troubleshooting Common issues and solutions
API Reference Complete MSBuild properties and tasks
Core Concepts How the build pipeline works
Architecture Internal architecture details

Requirements

  • .NET SDK 8.0+
  • EF Core Power Tools CLI - Auto-executed via dnx on .NET 10+; requires manual install on .NET 8-9
  • Database source - SQL Server Database Project (.sqlproj) or live database connection

Supported SQL Project Types

Type Extension Cross-Platform
Microsoft.Build.Sql .sqlproj Yes
MSBuild.Sdk.SqlProj .csproj / .fsproj Yes
Traditional SQL Projects .sqlproj Windows only

Samples

See the samples directory for complete working examples:

Contributing

Contributions are welcome! Please open an issue first to discuss changes. See CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License. See LICENSE for details.

Acknowledgments

  • EF Core Power Tools by Erik Ejlskov Jensen - The tool this package automates
  • Microsoft - For Entity Framework Core and MSBuild

Support