EFCore.Data.Repository 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package EFCore.Data.Repository --version 1.0.3                
NuGet\Install-Package EFCore.Data.Repository -Version 1.0.3                
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="EFCore.Data.Repository" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EFCore.Data.Repository --version 1.0.3                
#r "nuget: EFCore.Data.Repository, 1.0.3"                
#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 EFCore.Data.Repository as a Cake Addin
#addin nuget:?package=EFCore.Data.Repository&version=1.0.3

// Install EFCore.Data.Repository as a Cake Tool
#tool nuget:?package=EFCore.Data.Repository&version=1.0.3                

EFCore.Data.Repository

Repository written in C# for EntityFrameworkCore.

I can guess that you are encountering more than one repository. You can simply use the repository I have prepared in your projects. You can use directly generic repository while injecting in ctor. Since it's already generic, you only need to provide an entity. Let's setup it together.

###How to setup?

#####1. Creating Entity

    public class User
    {
        public Guid Identifier { get; set; }
        public string Username { get; set; }
        public string PasswordHash { get; set; }
        public string Email { get; set; }
    }

#####2.Creating Basic DbContext

public class ApplicationDbContext : DbContext
{
    private readonly IConfiguration _configuration;

    public ApplicationDbContext(IConfiguration configuration)
    {
        _configuration = configuration;
    }

    public DbSet<User> Users { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder options)
    {
        // Replace with your connection string.
        var connectionString = _configuration.GetConnectionString("TestDbConnection");

        options.UseSqlServer(connectionString);
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<User>();
    }
}

#####3.Creating Controller and Injecting Repository

[Route("api/[controller]")]
[ApiController]
public class UserController : ControllerBase
{
    private readonly IRepository<User> _repository;

    public UserController(IRepository<User> repository)
    {
        _repository = repository;
    }
}

#####3.Creating Endpoint and Using Repository with CRUD Operation

[Route("api/[controller]")]
[ApiController]
public class UserController : ControllerBase
{
    private readonly IRepository<User> _repository;

    public UserController(IRepository<User> repository)
    {
        _repository = repository;
    }

        #region Read

        [HttpGet]
        public async Task<IActionResult> GetAsync()
        {
            // Get list of data
            var data = await _repository.GetListAsync();

            return Ok(data);
        }

        [HttpGet("{id}")]
        public async Task<IActionResult> GetAsync(Guid id)
        {
            // Get data by id
            var data = await _repository.GetFirstOrDefaultAsync(x => x.Identifier == id);

            return Ok(data);
        }

        #endregion

        #region Create

        [HttpPost]
        public async Task<IActionResult> PostAsync(User user)
        {
            // Create
            await _repository.AddAsync(user);

            return Ok();
        }

        #endregion

        #region Update

        [HttpPut("{id}")]
        public async Task<IActionResult> PutAsync(User user)
        {
            // Get entity
            var entity = await _repository.GetFirstOrDefaultAsync(x => x.Identifier.Equals(user.Identifier));

            // Set new values
            entity.Username = user.Username;
            entity.Email = user.Email;
            entity.PasswordHash = user.PasswordHash;

            // Update
            await _repository.UpdateAsync(user);

            return NoContent();
        }

        #endregion

        #region Delete

        [HttpDelete("{id}")]
        public async Task<IActionResult> DeleteAsync(Guid id)
        {
            // Get entity
            var entity = await _repository.GetFirstOrDefaultAsync(x => x.Identifier.Equals(id));

            // Delete
            await _repository.DeleteAsync(entity);

            return Ok();
        }

        #endregion
}

#####4.DI container Registration

...
services.AddTransient<IRepository<User>, Repository<ApplicationDbContext, User>>();
...

Finally we did it. It will be continued to develop. You can fork. I will make a youtube video.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.5 249 11/5/2023
1.0.3 237 3/7/2023
1.0.2 212 3/7/2023
1.0.1 215 3/7/2023
1.0.0 219 3/7/2023