Aspnetcore.docs: How to config Identity for SQLite

Created on 8 Jan 2018  路  7Comments  路  Source: dotnet/AspNetCore.Docs

There are a couple steps to use SQLite with Identity.

@tdykstra can you provide notes?

@danroth27 can you or @divega set the priority.

Should this go in in Custom storage providers for ASP.NET Core Identity

Help wanted P2 doc-enhancement needs-more-info

Most helpful comment

Since the main docs point here, can we get a summary here of the steps to switch from SqlServer to Sqlite? I'm going in circles following the links and not finding a good summary. All I read is "I spent a lot of time to get it working" but no summary of how...

All 7 comments

I ran into a couple of difficulties, and it turned out that what I thought was an identity-specific issue was more generally about using SQLite with EF. With non-Identity EF I got an error message that told me I needed to create a ContextFactory class. When I ran add-migration on the Identity context I didn't get that helpful error message. Add-migration succeeded but update-database failed on an AddForeignKey operation. I added the ContextFactory class, and migrations and update-database worked flawlessly.

I spent a fair amount of time trying to figure out how to specify the SQLite file location, until I found a great summary of how the connection string works in a comment by @natemcmaster in this issue. If that's in a doc somewhere I didn't run across it. There is a connection string wiki page but it doesn't have this info.

@tdykstra the default for dotnet new webapp -au is SQLite. Doesn't that mean SQLite works with Identity?

It does work with Identity, but there are (or were when I tried to use it with Identity last January) gotchas that you have to guess and search to find out how to fix. The best place for this information is an introductory tutorial but the only thing I see like that in the TOC is the Learn module https://docs.microsoft.com/en-us/learn/modules/secure-aspnet-core-identity/?view=aspnetcore-3.1

Since the main docs point here, can we get a summary here of the steps to switch from SqlServer to Sqlite? I'm going in circles following the links and not finding a good summary. All I read is "I spent a lot of time to get it working" but no summary of how...

@dagilleland did you figure out how to configure Identity to use SQLite? I am trying to do the same thing and would love to not reinvent the wheel here if it's already known.

Actually I got this working really easily. I didn't realize that if I deleted the auto generated migration and create a new one it would generate for SQLite. It's working perfectly fine with SQLite and .NET Core 5 RC1.

Actually I got this working really easily. I didn't realize that if I deleted the auto generated migration and create a new one it would generate for SQLite. It's working perfectly fine with SQLite and .NET Core 5 RC1.

Yes, True.

I just deleted the Migration folder and then run the following command from NuGet Manager Commend

1) Install-Package Microsoft.EntityFrameworkCore.Tools
2) Add-Migration InitialCreate
3) Update-Database

However, you do need to update dotnet to 5.0 (to solve error Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 5.0.0 is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0) )

I hope this helps. Give me a review :-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fabich picture fabich  路  3Comments

royshouvik picture royshouvik  路  3Comments

Rick-Anderson picture Rick-Anderson  路  3Comments

davisnw picture davisnw  路  3Comments

YeyoCoder picture YeyoCoder  路  3Comments