I'm using Visual Studio 2017.
Create a new ASP.NET Web Forms Site project, targeting .Net Framework 4.7.1
Install Nuget Package AspNet.Identity.SQLite
ok, and wait till finish installing
Replace all text Microsoft.AspNet.Identity.EntityFramework with AspNet.Identity.SQLite for the Current Project.
It should have 5 occurrence replaced
Create a new Sqlite database name Identity.db into the App_Data folder for the current project
Open a Query Editor for the Sqlite database, the run the sql query.
You can get the query from the package folder inside your solution folder "AspNet.Identity.SQLite.1.0.6352.28669\content\SQLiteIdentity.sql"
Execute the query
In the IdentityModels.vb, replace the whole ApplicationDbContext class:
Public Class ApplicationDbContext Inherits IdentityDbContext(Of ApplicationUser) Public Sub New() MyBase.New("DefaultConnection") End Sub End Class
with this:
Public Class ApplicationDbContextInherits SQLiteDatabasePublic Sub New()MyBase.New("DefaultConnection")End SubEnd Class
The replace the UserManager class
Public Class UserManagerInherits UserManager(Of ApplicationUser)Public Sub New()MyBase.New(New UserStore(Of ApplicationUser)(New ApplicationDbContext()))End SubEnd Class
with this:
Public Class UserManagerInherits UserManager(Of ApplicationUser)Public Sub New()MyBase.New(New UserStore(Of ApplicationUser, IdentityRole)(New ApplicationDbContext()))End SubEnd Class
Lastly, replace the default connectionstring in the web.config with this
<connectionStrings><add name="DefaultConnection" connectionString="Data Source=|DataDirectory|\Identity.db;Version=3;" providerName="System.Data.SQLite"/></connectionStrings>
Done..
But, in case of error releted tu SQLite.Interop.dll when running, try following this step
Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found
No comments:
Post a Comment