forked from tugberkugurlu/AspNet.Identity.RavenDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.html
More file actions
48 lines (36 loc) · 2.89 KB
/
README.html
File metadata and controls
48 lines (36 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<h1>AspNet.Identity.RavenDB</h1>
<p>Fully asynchronous, new and sweet ASP.NET Identity implementation for RavenDB.</p>
<h2>Getting Started with Version 2.0.0</h2>
<p>Using ASP.NET Identity RavenDB port is pretty straight forward. You can install the <a href="https://www.nuget.org/packages/AspNet.Identity.RavenDB">AspNet.Identity.RavenDB</a> library through <a href="https://nuget.org">NuGet</a>. For now, the <strong>AspNet.Identity.RavenDB</strong> package which
targets the ASP.NET Identity 2.0.0 release is pre-release. So, be sure to use the <code>-pre</code> switch while getting it through NuGet:</p>
<pre><code>Install-Package AspNet.Identity.RavenDB -Pre
</code></pre>
<p>The following code snippet shows the easiest way to stand up the <code>UserManager<TUser></code> class with <code>RavenUserStore<TUser></code>:</p>
<pre><code>IDocumentStore documentStore = new DocumentStore
{
Url = "http://localhost:8080",
DefaultDatabase = "AspNetIdentity"
}.Initialize();
using (IAsyncDocumentSession session = documentStore.OpenAsyncSession())
{
session.Advanced.UseOptimisticConcurrency = true;
RavenUserStore<RavenUser> ravenUserStore = new RavenUserStore<RavenUser>(session);
UserManager<RavenUser> userManager = new UserManager<RavenUser>(ravenUserStore);
// UserManager<RavenUser> is ready to use!
}
</code></pre>
<p>Couple of things to note here:</p>
<ul>
<li><p>You MUST set the <code>UseOptimisticConcurrency</code> flag to <code>true</code> on the <code>IAsyncDocumentSession</code> as shown above
and leave it enabled till the end of the <code>IAsyncDocumentSession</code> lifetime because we need to ensure the uniqueness
of the username and the email. <code>RavenUserStore<TUser></code> checks if you enabled optimistic concurrency or not on its constructor. If you didn't,
it will throw an exception. However, optimistic concurrency can be disabled any time during the <code>IAsyncDocumentSession</code>
lifetime by the session provider. That's why the library cannot possibly be sure to warn 100% of the time. So, it is extremely important to
obey this rule and leave the optimistic concurrency enabled on the session till the end of its lifetime. Otherwise, you will have a chance of
ending up overriding an existing user's data if a new user tries to register with the username of that existing user (which would be chaotic for you)!</p></li>
<li><p>You don't need to use <code>RavenUser</code> entity type. However, your custom entity class must be derived from <code>RavenUser</code> class.</p></li>
</ul>
<h2>Resources for Version 1.0.0</h2>
<ul>
<li><a href="http://www.tugberkugurlu.com/archive/aspnet-identity-ravendb--fully-asynchronous-new-and-sweet-asp-net-identity-implementation-for-ravendb">Introduction Blog Post: AspNet.Identity.RavenDB: Fully asynchronous, new and sweet ASP.NET Identity implementation for RavenDB</a></li>
</ul>