Git Product home page Git Product logo

aspnet-identity-litedb's Introduction

AspNet.Identity.LiteDB

This library is an ASP.NET Identity provider that uses LiteDB storage implementation. I based this code on this MongoDB AspNet Identity provider MongoDB.AspNet.Identity.

Instructions

  1. Create a new ASP.NET MVC 5 project, choosing the Individual User Accounts authentication type.
  2. Remove the Entity Framework packages and replace with AspNet:
Uninstall-Package Microsoft.AspNet.Identity.EntityFramework
Uninstall-Package EntityFramework
Install-Package AspNet.Identity.LiteDB
  1. In ~/Models/IdentityModels.cs:
    • Remove the namespace: Microsoft.AspNet.Identity.EntityFramework
    • Add the namespace: AspNet.Identity.LiteDB
    • Remove the entire ApplicationDbContext class. You won't need that at all.
  2. Add the following class to the App_Start folder
namespace YourNamespace
{
	using System;
	using System.Web.Hosting;
	using AspNet.Identity.LiteDB;
	using LiteDB;
	using Models;

	public class DbContext : IDisposable
	{
		private readonly LiteDatabase _database;

		public DbContext()
		{
			// TODO: path to your database here
			_database = new LiteDatabase(HostingEnvironment.MapPath("/App_Data/Chainline.db"));
		}

		public static DbContext Create()
		{
		    return new DbContext();
		}

		public LiteCollection<ApplicationUser> Users => _database.GetCollection<ApplicationUser>("users");

		public LiteCollection<IdentityRole> Roles => _database.GetCollection<IdentityRole>("roles");

		public void Dispose() { }
	}
}
  1. In Startup.Auth.cs replace the following line:
    • app.CreatePerOwinContext(ApplicationDbContext.Create);
    • with:
    • app.CreatePerOwinContext(DbContext.Create);
  2. In IdentityConfig.cs:
    • Remove the namespace: Microsoft.AspNet.Identity.EntityFramework
    • In the ApplicationUserManager.Create() method, replace the line:
      • var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
      • with:
      • var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<DbContext>().Users));

... More to come...

Thanks To

Special thanks to g0t4. My implementation is based off his MongoDB implementation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.