_contextFactory.CreateDbContext() not working

Advertisements I use these statements: using (var factory = _contextFactory.CreateDbContext()) { var itemsQueryable = factory.Set<AppUser>().AsQueryable(); var result = itemsQueryable?.Where(c => c.AccessFailedCount <= maxMedals); … } this is a factory of my identityContext, but when I run the code, there is an error: System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error… Read More _contextFactory.CreateDbContext() not working

Injecting Generic Service

Advertisements I am Injecting GenericRepository into BL service that calles it in order to get data from entity framework. No Exception is thrown until I am trying to add the other BL Service as scoped I get the following Exception: System.AggregateExceptionHResult=0x80131500 Message=Some services are not able to be constructed (Error while validating the service descriptor… Read More Injecting Generic Service

EF Core async LINQ Where(predicate).ToListAsync() Error: CS1061 IEnumerable does not contain ToListAsync()

Advertisements So I have a context class EFCoreMContext with defined property EFCore.DBSet<AccessTime> AccessTime public class EFCoreMContext : Microsoft.EntityFrameworkCore.DbContext { public Microsoft.EntityFrameworkCore.DbSet<User> Users { get; set; } public Microsoft.EntityFrameworkCore.DbSet<AccessTime> AccessTime { get; set; } … } Then I have a repository class CAccessTimeRepository public class CAccessTimeRepository : IRepository<AccessTime> { private EFCoreMContext db; public CAccessTimeRepository(EFCoreMContext context) {… Read More EF Core async LINQ Where(predicate).ToListAsync() Error: CS1061 IEnumerable does not contain ToListAsync()

Cannot implicitly convert type probably in controller

Advertisements I am receiving the following error: Cannot implicitly convert type: ‘Microsoft.EntityFrameworkCore.DbContextOptions<TvApi.Data.TvMazeContext>’ to ‘TvApi.Data.TvMazeContext’ TvApi Something is wrong in this part db = context of my controller but I don’t know what: public ShowsController(ILogger<ShowsController> logger, DbContextOptions<TvMazeContext> context) { _logger = logger; db = context; } This is my controller: using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using TvApi.Data;… Read More Cannot implicitly convert type probably in controller

List of enums EF Core LINQ query

Advertisements public enum GeneticModificationTypes { SomeType = 1, AnotherType = 2, ThirdType = 3 } public class GeneticModification: FullAuditedEntity<Guid> { public ICollection<GeneticModificationTypes> Types { get; set; } } modelBuilder.Entity<GeneticModification>() .Property(e => e.Types) .HasConversion( v => string.Join(‘,’, v), v => v.Split(‘,’, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<GeneticModiciation>()) .Metadata.SetValueComparer(valueComparer); var valueComparer = new ValueComparer<ICollection<string>>( (c1, c2) => c1.SequenceEqual(c2), c… Read More List of enums EF Core LINQ query