Razory.EntityFramework
2.1.1
dotnet add package Razory.EntityFramework --version 2.1.1
NuGet\Install-Package Razory.EntityFramework -Version 2.1.1
<PackageReference Include="Razory.EntityFramework" Version="2.1.1" />
<PackageVersion Include="Razory.EntityFramework" Version="2.1.1" />
<PackageReference Include="Razory.EntityFramework" />
paket add Razory.EntityFramework --version 2.1.1
#r "nuget: Razory.EntityFramework, 2.1.1"
#:package Razory.EntityFramework@2.1.1
#addin nuget:?package=Razory.EntityFramework&version=2.1.1
#tool nuget:?package=Razory.EntityFramework&version=2.1.1
Razory.EntityFramework
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:
IEFDatabaseConfigurationandIDatabaseConfiguration→ your configuration (singleton)RazoryDbContextwith your optionsIRepository→EFRepositoryIQueryObject<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
| Product | Versions 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. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.3)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Razory (>= 2.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.