services.AddDbContext<CasbinDbContext<int>>(options =>
{
DbContextOptionsBuilder optionsBuilder = null;
switch (type.ToLower())
{
case "mysql":
optionsBuilder = options.UseMySQL(connectionString);
break;
case "sqlite3":
default:
optionsBuilder = options.UseSqlite(connectionString);
break;
}
var context = new CasbinDbContext<int>(optionsBuilder.Options);
context.Database.EnsureCreated();
}, ServiceLifetime.Transient);
Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Casbin.Adapter.EFCore.CasbinDbContext`1[System.Int32] Lifetime: Transient ImplementationType: Casbin.Adapter.EFCore.CasbinDbContext`1[System.Int32]': Unable to activate type 'Casbin.Adapter.EFCore.CasbinDbContext`1[System.Int32]'. The following constructors are ambiguous:
Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions, System.String, System.String)
Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions`1[Casbin.Adapter.EFCore.CasbinDbContext`1[System.Int32]], System.String, System.String))