casbin-net / efcore-adapter

Entity Framework Core Adapter for Casbin.NET
https://github.com/casbin/Casbin.NET
Apache License 2.0
47 stars 21 forks source link

Unable resolve CasbinDbContext #46

Closed hanaimin closed 3 years ago

hanaimin commented 3 years ago
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))
hanaimin commented 3 years ago

image

hsluoyz commented 3 years ago

@Sagilio

hsluoyz commented 3 years ago

@Sagilio plz make a release

hsluoyz commented 3 years ago

@hanaimin https://github.com/casbin-net/EFCore-Adapter/releases/tag/v1.7.1