Search code examples
silverlightentity-frameworkwcf-ria-servicescustom-authenticationentityobject

Developing custom authorization service with Entity-Framework and Silverlight WCF RIA-Services?


I am desperately trying to develop with RIA services, but I want the User and Role classes to be entities generated by the EDM designer.
The problem with that is, that I can't inherit from UserBase, since the entity already inherits from EntityObject.
I tried to follow what I've read in few discussions over the net, and I implemented the partial class of the User with the IUser interface, having the AuthenticationService inherit from LinqToEntitiesDomainService<MyEntities> and implement IAuthentication<User>.

But since I feel that it's a dead end since I keep on getting errors everywhere with no result, I thought I might post my question to those who have been thru it and are willing to share the knowledge they've been fighting for, and make my life easier.

I beg you, please only share ideas that you have experience with, I've spent a lot of time finding the solution.

UPDATE:
I managed to make it compile and run, but now I have a very weird situation: After several seconds that the application runs, it vanishes (I use Out-Of-Browser), the window frame remains, but no content!

Here is what I've done to make it compile:

  • Generate the Entity Model entities
  • Make the User class implement IUser
  • Mark the implemented Name property that returns the username with Key and DataMember attributes
  • Attribute DataMember on the Roles property
  • Then I run the project, it does compile but the content disappears after several seconds, without letting me know the source of the internal exception!

I could just tell that the vanishment occurs after the following is printed in the output window:

'sllauncher.exe' (Silverlight): Loaded 'ProxyBuilder'

Then, when it disappears, it writes:

'sllauncher.exe' (Silverlight): Loaded 'C:\Program Files (x86)\Microsoft Silverlight\4.0.50917.0\en-US\System.Runtime.Serialization.debug.resources.dll'
'sllauncher.exe' (Silverlight): Loaded 'C:\Program Files (x86)\Microsoft Silverlight\4.0.50917.0\en-US\mscorlib.debug.resources.dll'

Resources I've been thru:


Solution

  • Turns out that Nikhil Kothari, has already done this work for us, it's included in the RiaEssentials project.

    Read this blog for detail.