Reputation: 1
I am facing a challenge while implementing a generic repository with a unit of work pattern in my ASP.NET Core project. The issue arises when I attempt to inherit from IdentityDbContext in my custom MyBlogDbContext, causing the following error:
ERROR!!! : CS1503 : Argument 1: Cannot convert 'MyBlogDAL.Context.MyBlogDbContext' to 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext'.
To provide some context, I've included a snippet of my generic repository implementation below:
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using MyBlogDAL.Context;
using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal;
using MyBlogDAL.Repositories.Abstract;
using MyBlogDomain.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace MyBlogDAL.Repositories.Concrete
{
public class GenericRepository<T> : IRepository<T> where T : class
{
protected readonly DbContext Context;
public GenericRepository(DbContext Context)
{
this.Context = Context;
}
public async Task AddAsync(T entity)
{
await Context.Set<T>().AddAsync(entity);
}
I would appreciate any guidance or suggestions on how to effectively integrate Identity with a generic repository, or if there's an alternative approach to achieve the desired functionality.
Thank you in advance for your assistance!
Upvotes: 0
Views: 31