EntityFrameworkSandbox.Template 0.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet new install EntityFrameworkSandbox.Template::0.0.6                
This package contains a .NET Template Package you can call from the shell/command line.

Entity Framework Sandbox

The Entity Framework Sandbox is a CLI project template that allows you to quickly spin up a functioning project running on the latest version of EF with a real database and real data.

This can be useful in the following scenario:

  • Exploring new features of EF such as
  • Safely exploring changes to a real application
  • Replicating EF issues in an isolated environment

This is not intended to be a starting point for a production application.

Prerequisites

  • VS2022
  • .NET 7
  • LocalDB

Setup

Template Installation

Install the dotnet CLI template via:

dotnet new --install EntityFrameworkSandbox.Template 

Project Creation

You can use the template to create a new project via:

mkdir my-ef-sandbox
cd my-ef-sandbox
dotnet new ef-sandbox

Alternatively, you can create the project directly into a new sub-folder via:

dotnet new ef-sandbox --name my-sub-folder

Usage

Writing Commands & Queries

  • Ensure the connection matches if you are using something other than local DB
  • Update the Sandbox to run your own EF queries and commands
private async Task RunQueries()
{
    // NOTE: Further DB queries go here
}
private Task RunCommands()
{
    // NOTE: Further DB commands go here
}

Overriding Model Configuarion

This can be done in the configuration classes:

internal class PostConfiguration : IEntityTypeConfiguration<Post>
{
    public void Configure(EntityTypeBuilder<Post> builder)
    {
        // NOTE: Custom model configuration goes here
    }
}

Schema Changes

The project is designed to use migrations for schema upgrades. However, if you prefer to instead drop and create the DB everytime you can set Application.EnableMigrations to false in appsettings.json:

"Application": {
    "EnableMigrations": false
}

Run the Project

  • Press F5
    • Console up will start
    • By default, DB will be dropped & re-created
    • Data will be seeded
    • SQL queries will run
    • All SQL and results output to console

This package has no dependencies.

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.1.0 1,038 2/27/2023
1.0.1 392 1/8/2023
1.0.0 338 1/7/2023
0.0.7 334 1/6/2023
0.0.6 436 11/13/2022
0.0.5 370 11/13/2022
0.0.4 331 11/12/2022
0.0.3 350 11/12/2022
0.0.2 376 11/12/2022
0.0.1 365 11/12/2022