Casbin.NET icon indicating copy to clipboard operation
Casbin.NET copied to clipboard

Is Casbin.NET v2 incompatible with EFCore Adapter and AspNetCore?

Open shayura opened this issue 3 years ago • 2 comments

I'm using Casbin.NET v2 in order to take advantage of EnforcerContext (please see #240 for reference.) I've noticed that neither EFCore Adapter nor the AspNetCore extension work with this version of the tool because the assembly name change from CasbinNet to just Casbin.

This is the specific error the compiler is spewing out:

[CS0012] The type 'IFilteredAdapter' is defined in an assembly that is not referenced. 
You must add a reference to assembly 'NetCasbin, Version=1.12.1.0, Culture=neutral, PublicKeyToken=null'.

I'm still new to Microsoft's .NET stack and the C# language. It's completely possible that I misunderstood the meaning of this error, but I did notice the namespace change.

Unless there's a way to query query the enforcer for pN rules, I can't afford to downgrade to the previous version of Casbin.NET. Do you have any advice?

The error is happening with this code

var enforcer = new Enforcer(
    DefaultModel.CreateFromFile(Path.Combine("CasbinConfig", "model.conf"), 
    new EFCoreAdapter<int>(_casbinDbContext));

when using the following versions of the Casbin packages:

  • Casbin.NET 2.0.0-preview.2
  • Casbin.AspNetCore 0.2.1
  • Casbin.Adapter.EFCore 1.8.0

shayura avatar Feb 18 '22 19:02 shayura

@sagilio @xcaptain @huazhikui

casbin-bot avatar Feb 18 '22 19:02 casbin-bot

@sagilio

hsluoyz avatar Feb 19 '22 01:02 hsluoyz

The release of Casbin.Adapter.EFCore and Casbin.AspNetCore is only work for Casbin.NET v1.

I will release 2.x versions of them that are compatible with the Casbin.NET v2 this year.

sagilio avatar Feb 25 '22 09:02 sagilio

@sagilio any update?

@sociometry

hsluoyz avatar Jun 24 '22 16:06 hsluoyz

@shayura Casbin.AspNetCore and Casbin.Adapter.EFCore latest versions have supported Casbin.NET 2.x now.

hsluoyz avatar Apr 04 '24 14:04 hsluoyz