Choosing A Different Storage Mechanism For MembershipReboot

MembershipReboot is designed with a flexible account storage mechanism, and EF being the default. With this flexibility in mind you can create your own storage mechanism using something like NHibernate, Simple.Data or one for a NoSQL database. In my previous post  I showed how to  setup MR(MembershipReboot) for use in your project using EF. If you’d like to create your own custom storage mechanism, your will find guideline here. Aside EF, you can decide to store your data in a NoSQL database. As of this writing, there are repository implementation for MongoDb & RavenDB (but no nuget packages yet), and a single tenant web app sample that utilizes it from the samples directory in the GitHub repo.

For you to use the MongoDb repository, you’ll need to add a reference to BrockAllen.MembershipReboot.MongoDb, if RavenDb is your choice, then, reference BrockAllen.MembershipReboot.RavenDb . If you use dependency injection, then you’ll have to configure the container to resolve request for  a concrete implementation of  IUserAccountRepository to MongoUserAccountRepository or RavenUserAccountRepository for MongoDb or RavenDb.

Here’s a sample code using Ninject & MongoDb:

kernel.Bind<MembershipRebootConfiguration<HierarchicalUserAccount>>().ToSelf();
kernel.Bind<UserAccountService<HierarchicalUserAccount>>().ToSelf();
kernel.Bind<AuthenticationService<HierarchicalUserAccount>>().To<SamAuthenticationService<HierarchicalUserAccount>>();
kernel.Bind<MongoDatabase>().ToSelf().WithConstructorArgument("connectionStringName", "MongoDb");
kernel.Bind<IUserAccountRepository<HierarchicalUserAccount>>().To<MongoUserAccountRepository>();
kernel.Bind<IUserAccountQuery>().To<MongoDb.MongoUserAccountRepository>();

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s