FastProjects.Data.EntityFrameworkCore 1.0.1

dotnet add package FastProjects.Data.EntityFrameworkCore --version 1.0.1                
NuGet\Install-Package FastProjects.Data.EntityFrameworkCore -Version 1.0.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="FastProjects.Data.EntityFrameworkCore" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FastProjects.Data.EntityFrameworkCore --version 1.0.1                
#r "nuget: FastProjects.Data.EntityFrameworkCore, 1.0.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.
// Install FastProjects.Data.EntityFrameworkCore as a Cake Addin
#addin nuget:?package=FastProjects.Data.EntityFrameworkCore&version=1.0.1

// Install FastProjects.Data.EntityFrameworkCore as a Cake Tool
#tool nuget:?package=FastProjects.Data.EntityFrameworkCore&version=1.0.1                

To configure the repository template:


πŸš€ FastProjects.Data.EntityFrameworkCore

Build Status NuGet NuGet Downloads License Last Commit GitHub Stars GitHub Forks

🚨 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


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 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. 
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
1.0.1 104 9/18/2024
1.0.0 104 9/18/2024