Visium.Anima.EntityFrameworkCore.SourceGeneration 1.0.0-alpha.7

This is a prerelease version of Visium.Anima.EntityFrameworkCore.SourceGeneration.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Visium.Anima.EntityFrameworkCore.SourceGeneration --version 1.0.0-alpha.7
                    
NuGet\Install-Package Visium.Anima.EntityFrameworkCore.SourceGeneration -Version 1.0.0-alpha.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Visium.Anima.EntityFrameworkCore.SourceGeneration" Version="1.0.0-alpha.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Visium.Anima.EntityFrameworkCore.SourceGeneration" Version="1.0.0-alpha.7" />
                    
Directory.Packages.props
<PackageReference Include="Visium.Anima.EntityFrameworkCore.SourceGeneration" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Visium.Anima.EntityFrameworkCore.SourceGeneration --version 1.0.0-alpha.7
                    
#r "nuget: Visium.Anima.EntityFrameworkCore.SourceGeneration, 1.0.0-alpha.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Visium.Anima.EntityFrameworkCore.SourceGeneration&version=1.0.0-alpha.7&prerelease
                    
Install Visium.Anima.EntityFrameworkCore.SourceGeneration as a Cake Addin
#tool nuget:?package=Visium.Anima.EntityFrameworkCore.SourceGeneration&version=1.0.0-alpha.7&prerelease
                    
Install Visium.Anima.EntityFrameworkCore.SourceGeneration as a Cake Tool

Anima.EntityFrameworkCore.SourceGeneration

Source generators to reduce boilerplate code when working with EntityFrameworkCore.

GenerateDbSets

This feature eases the burden of manually adding entities to the DbContext every time a new entity class is created.

Usage

Set the project's DbContext class as partial and mark it with the [GenerateDbSets] attribute to automatically generate DbSet properties for every class in the project that implements IEntityTypeConfiguration.

Example

Given the following classes:

[GenerateDbSets]
public partial class DatabaseContext : DbContext
{
    public DatabaseContext() { } // Parameterless constructor for dotnet ef
    
    public DatabaseContext(DbContextOptions<DatabaseContext> options)
    {
        // Configure the database here
    }
    
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        // Add entity configurations from classes that implement IEntityTypeConfiguration
        modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetAssembly(typeof(DatabaseContext))!);
        base.OnModelCreating(modelBuilder);
    }
}
public class User : IEntityTypeConfiguration<User>
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    
    public ICollection<Session> Sessions { get; set; } = new HashSet<Session>();
    
    public void Configure(EntityTypeBuilder<User> builder)
    {
        builder.Property(e => e.FirstName).HasMaxLength(50);
        builder.Property(e => e.LastName).HasMaxLength(50);
    }
}
public class Session : IEntityTypeConfiguration<User>
{
    public int Id { get; set; }
    
    public User User { get; set; }
    public int UserId { get; set; }
    
    public string Platform { get; set; }
    public DateTime LoginTime { get; set; }
    public DateTime? LogoutTime { get; set; }
    
    public void Configure(EntityTypeBuilder<User> builder)
    {
        builder.Property(e => e.Platform).HasMaxLength(20);
    }
}

This output will be generated:

public partial class DatabaseContext
{
    public DbSet<User> Users { get; set; }
    public DbSet<Session> Sessions { get; set; }
}
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • 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.0.0-alpha.15 119 4/24/2025
1.0.0-alpha.14 121 4/24/2025
1.0.0-alpha.13 117 4/24/2025
1.0.0-alpha.12 118 4/3/2025
1.0.0-alpha.11 64 7/15/2024
1.0.0-alpha.10 77 4/12/2024
1.0.0-alpha.9 69 4/12/2024
1.0.0-alpha.8 67 4/10/2024
1.0.0-alpha.7 68 4/9/2024
1.0.0-alpha.6 69 4/9/2024
1.0.0-alpha.5 74 4/7/2024
1.0.0-alpha.4 71 4/7/2024