Razory.EntityFramework 2.1.1

dotnet add package Razory.EntityFramework --version 2.1.1
                    
NuGet\Install-Package Razory.EntityFramework -Version 2.1.1
                    
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="Razory.EntityFramework" Version="2.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Razory.EntityFramework" Version="2.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Razory.EntityFramework" />
                    
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 Razory.EntityFramework --version 2.1.1
                    
#r "nuget: Razory.EntityFramework, 2.1.1"
                    
#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.
#:package Razory.EntityFramework@2.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Razory.EntityFramework&version=2.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Razory.EntityFramework&version=2.1.1
                    
Install as a Cake Tool

Razory.EntityFramework

Build & Test NuGet License: MIT

Entity Framework Core provider for Razory. Implements IRepository and IQueryObject<T> using DbContext and IQueryable.

Installation

dotnet add package Razory.EntityFramework

Setup

1. Implement IEFEntityConfiguration<T> for each entity

IEFEntityConfiguration<T> extends both IEntityConfiguration<T> (for the table name) and EF Core's IEntityTypeConfiguration<T> (for the model builder):

public class ProductConfiguration : IEFEntityConfiguration<Product>
{
    public string Name => "Products"; // table name

    public void Configure(EntityTypeBuilder<Product> builder)
    {
        builder.HasKey(p => p.Id);
        builder.Property(p => p.Name).IsRequired().HasMaxLength(200);
        builder.Property(p => p.Category).HasMaxLength(100);
    }
}

2. Implement IEFDatabaseConfiguration

IEFDatabaseConfiguration extends IDatabaseConfiguration and adds Configure(DbContextOptionsBuilder) to wire up the EF Core provider:

public class MyEFDatabaseConfiguration : IEFDatabaseConfiguration
{
    private readonly List<IEntityConfiguration> configurations =
    [
        new ProductConfiguration(),
        new OrderConfiguration(),
    ];

    public string ConnectionString => "Server=localhost;Database=my_db;Trusted_Connection=True;";

    public void Configure(DbContextOptionsBuilder optionsBuilder) =>
        optionsBuilder.UseSqlServer(ConnectionString);

    public string GetDatabaseName<T>() where T : EntityBase => "my_db";

    public IEntityConfiguration<T> GetEntityConfiguration<T>() where T : EntityBase =>
        configurations.OfType<IEntityConfiguration<T>>().Single();

    public IEnumerable<IEntityConfiguration> GetAllEntityConfigurations() => configurations;
}

3. Register

builder.Services.ConfigureRazoryEntityFramework(new MyEFDatabaseConfiguration());

This registers:

  • IEFDatabaseConfiguration and IDatabaseConfiguration → your configuration (singleton)
  • RazoryDbContext with your options
  • IRepositoryEFRepository
  • IQueryObject<T>EFQueryObject<T>

RazoryDbContext reads all entity configurations from IEFDatabaseConfiguration and applies them automatically via OnModelCreating — no need to create a custom DbContext.

Usage

Inject IRepository for CRUD and IQueryObject<T> for queries:

public class ProductService(IRepository repository, IQueryObject<Product> query)
{
    public Task<Product> GetByIdAsync(Guid id) =>
        repository.GetAsync<Product>(id);

    public Task InsertAsync(Product product) =>
        repository.InsertAsync(product);

    public Task UpsertAsync(Product product) =>
        repository.UpsertAsync(p => p.Id == product.Id, product);

    public Task<IEnumerable<Product>> GetActiveByCategoryAsync(string category) =>
        query
            .FilterBy<ProductFilter>(f => f.ActiveOnly().WithCategory(category))
            .SortAscending(p => p.Name)
            .Query()
            .GetAllAsync();

    public Task<IEnumerable<Product>> GetPageAsync(int page, int size) =>
        query
            .FilterBy(p => p.IsActive)
            .Query()
            .Skip((page - 1) * size)
            .Limit(size)
            .GetAllAsync();
}

Aggregate support

var grouped = await query
    .FilterBy(p => p.IsActive)
    .Aggregate()
    .Group(p => p.Category, g => new { Category = g.Key, Count = g.Count() })
    .GetAllAsync();

Repository

github.com/johnyricalde/Razory

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.1.1 112 3/28/2026
2.1.0 107 3/28/2026
2.0.1 102 3/26/2026
2.0.0 105 3/26/2026