< Summary

Class:MUNity.Database.Context.DbContextFactory<T>
Assembly:MUNity.Database
File(s):C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNityDatabase\Context\DbContextFactory.cs
Covered lines:0
Uncovered lines:11
Coverable lines:11
Total lines:30
Line coverage:0% (0 of 11)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)
Covered methods:0
Total methods:2
Method coverage:0% (0 of 2)

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%10%
CreateDbContext()0%20%

File(s)

C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNityDatabase\Context\DbContextFactory.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Threading.Tasks;
 5using Microsoft.EntityFrameworkCore;
 6using Microsoft.Extensions.DependencyInjection;
 7
 8namespace MUNity.Database.Context;
 9
 10public class DbContextFactory<TContext>
 11    : IDbContextFactory<TContext> where TContext : DbContext
 12{
 13    private readonly IServiceProvider provider;
 14
 015    public DbContextFactory(IServiceProvider provider)
 016    {
 017        this.provider = provider;
 018    }
 19
 20    public TContext CreateDbContext()
 021    {
 022        if (provider == null)
 023        {
 024            throw new InvalidOperationException(
 025                $"You must configure an instance of IServiceProvider");
 26        }
 27
 028        return ActivatorUtilities.CreateInstance<TContext>(provider);
 029    }
 30}

Methods/Properties

.ctor(...)
CreateDbContext()