1

I am using (Code First) Entity Framework 4.3 for an ASP.NET MVC project, and wanted to implement granular Permission based authorization features as provided by Rhino Security

Though it is the only such Permission based Lib available, but it's not yet been ported to EF. What can be the reason,

  1. Such a Permission Framework is not a usual requirement in projects, so it's not so famous
  2. Entity Framework is not so effective and so is not as ubiquitous as NHibernate
  3. Rhino Repository is so tightly coupled with NHibernate that it's not possible to simply port it to EF

Most Important, If i really insist on using it with EF, and if you tell me it's not possible, can you please help me understand why. And if your answer is in YES, can you please help me with HOW TO DO IT


ANY OTHER IDEAS please

If I really get started implementing it using EF, would it be a futile endeavor. Any complications i would face.

As I am just a newbie both with Entity Framework and MVC, is there anything I am overlooking. So, please help me all GENIUSES out there.

Any ideas how to get started?

WiseGuy
  • 11
  • 2

2 Answers2

3

My opinion:

It cannot be ported directly. Rhino-Security follows concept of separating (abstracting) security from your domain model. This separation is done through IUser interface. Implementing IUser interface in your User class will be the only connection between your domain model and the security infrastructure provided by the framework. Here comes the problem. EF doesn't currently support interfaces so you cannot use an interface instead of a real entity type in the mapping and you cannot have an interface instead of a real entity type as a navigation property in your entities. Because of that Rhino-Security cannot be ported to EF without crippling its main idea - you will have to create User entity directly in ported security library and all applications will have to be dependent on that User implementation.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • So, if i decide to yield to the idea of coupling the Security Framework with Model, by creating a user entity, any other issue you see? And how do i start with it? – WiseGuy Mar 20 '12 at 09:32
  • And what are the important point I must keep in mind, considering especially the performance implications. – WiseGuy Mar 20 '12 at 09:38
  • Those are question which cannot be easily answered without trying to make the port - you will have to find the answer yourselves. I didn't dig deeper into the implementation. I know only basics. – Ladislav Mrnka Mar 20 '12 at 09:45
1

I'd say the third answer:

Rhino Repository is so tightly coupled with NHibernate that it's not possible to simply port it to EF

I'm not sure about what's the reason behind that, but I'm sure it's closely bounded to NHibernate (or to Castle Active Record, that is based on NHibernate)

themarcuz
  • 2,573
  • 6
  • 36
  • 53