FastProjects.Data.EntityFrameworkCore
1.0.0
See the version list below for details.
dotnet add package FastProjects.Data.EntityFrameworkCore --version 1.0.0
NuGet\Install-Package FastProjects.Data.EntityFrameworkCore -Version 1.0.0
<PackageReference Include="FastProjects.Data.EntityFrameworkCore" Version="1.0.0" />
paket add FastProjects.Data.EntityFrameworkCore --version 1.0.0
#r "nuget: FastProjects.Data.EntityFrameworkCore, 1.0.0"
// Install FastProjects.Data.EntityFrameworkCore as a Cake Addin #addin nuget:?package=FastProjects.Data.EntityFrameworkCore&version=1.0.0 // Install FastProjects.Data.EntityFrameworkCore as a Cake Tool #tool nuget:?package=FastProjects.Data.EntityFrameworkCore&version=1.0.0
To configure the repository template:
π FastProjects.Data.EntityFrameworkCore
π¨ ALERT: Project Under Development This project is not yet production-ready and is still under active development. Currently, it's being used primarily for personal development needs. However, contributions are more than welcome! If you'd like to collaborate, feel free to submit issues or pull requests. Your input can help shape the future of FastProjects!
π Overview
FastProjects.Data.EntityFrameworkCore is a library that provides a base DbContext class with MassTransit outbox support. It's designed to be used in conjunction with the FastProjects framework, but it can also be used as a standalone library.
π Roadmap
- β AppDbContextBase - Base class for DbContext that provides outbox support for MassTransit
- β EfCoreRepositoryBase - Base class for repository that provides CRUD operations for entities
- β NpgsqlConnectionFactory - Factory class for creating NpgsqlConnection objects
- β³ OutBoxProcessingJob - Background job for processing outbox messages to handle MediatR events after transaction commit
- β³ OutBoxProcessingJobConfiguration - Configuration class for OutBoxProcessingJob
Usage
Registering the services:
builder.Services.AddDbContext<AppDbContext>(x =>
{
string connectionString = builder.Configuration.GetConnectionString("DefaultConnection")!;
x.UseNpgsql(connectionString);
});
builder.Services.AddScoped<IUnitOfWork>(sp => sp.GetRequiredService<AppDbContext>());
builder.Services.AddScoped<IDomainEventDispatcher, MediatRDomainEventDispatcher>();
builder.Services.AddScoped(typeof(IRepository<>), typeof(EfCoreRepository<>));
builder.Services.AddScoped(typeof(IReadRepository<>), typeof(EfCoreRepository<>));
builder.Services.AddScoped(typeof(EfCoreRepository<ProjectModel>));
builder.Services.AddSingleton<ISqlConnectionFactory>(_ =>
new NpgsqlConnectionFactory(builder.Configuration.GetConnectionString("DefaultConnection")!));
Classes:
// DbContext
public sealed class AppDbContext(
DbContextOptions<AppDbContext> options,
IDomainEventDispatcher? domainEventDispatcher)
: AppDbContextBase(options, domainEventDispatcher), IUnitOfWork
{
protected override Assembly ExecutingAssembly => Assembly.GetExecutingAssembly();
public DbSet<ProjectModel> Projects => Set<ProjectModel>();
}
// Generic Repository
public class EfCoreRepository<T>(AppDbContext appDbContext)
: EfCoreRepositoryBase<T>(appDbContext)
where T : class, IAggregateRoot;
// Usage
public sealed class CreateProjectCommandHandler(
EfCoreRepository<ProjectModel> projectCoreRepository,
IUnitOfWork unitOfWork)
: SharedKernel.ICommandHandler<CreateProjectCommand>
{
public async Task<Result> Handle(CreateProjectCommand request, CancellationToken cancellationToken)
{
var newProject = ProjectModel.Create(Guid.NewGuid(), request.Name);
await projectCoreRepository.AddAsync(newProject, cancellationToken);
await unitOfWork.SaveChangesAsync(cancellationToken);
return Result.Success();
}
}
π Installation
You can download the NuGet package using the following command to install:
dotnet add package FastProjects.Data.EntityFrameworkCore
π€ Contributing
This project is still under development, but contributions are welcome! Whether youβre opening issues, submitting pull requests, or suggesting new features, we appreciate your involvement. For more details, please check the contribution guide. Letβs build something amazing together! π
π License
FastProjects is licensed under the MIT License. See the LICENSE file for full details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- FastProjects.SharedKernel (>= 1.0.7)
- MassTransit.EntityFrameworkCore (>= 8.2.5)
- Microsoft.EntityFrameworkCore (>= 8.0.8)
- Npgsql (>= 8.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.