Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instructions for in-mem DB and show SQL output #21959

Closed
Rick-Anderson opened this issue Apr 1, 2021 · 0 comments
Closed

Add instructions for in-mem DB and show SQL output #21959

Rick-Anderson opened this issue Apr 1, 2021 · 0 comments
Assignees
Labels
doc-enhancement Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

@Rick-Anderson
Copy link
Contributor

Rick-Anderson commented Apr 1, 2021

Update StartupSQLite with the following code.

public void ConfigureServices(IServiceCollection services)
{
    services.AddRazorPages();

#if !IN_MEM
    services.AddDbContext<SchoolContext>(options =>
            options.UseSqlite(Configuration.GetConnectionString("SchoolContext")));
#else

    services.AddDbContext<SchoolContext>(options =>
options.UseInMemoryDatabase("InMemorySchoolContext"));
#endif

    services.AddDatabaseDeveloperPageExceptionFilter();
}

Doesn't work with concurrency, see dotnet/efcore#10625

Also add section on showing SQL output. See https://stackoverflow.com/a/66662556/502537


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@dotnet-bot dotnet-bot added ⌚ Not Triaged Source - Docs.ms Docs Customer feedback via GitHub Issue labels Apr 1, 2021
@Rick-Anderson Rick-Anderson changed the title Add instructions for in-mem DB Add instructions for in-mem DB and show SQL output Apr 16, 2021
@Rick-Anderson Rick-Anderson self-assigned this Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-enhancement Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

No branches or pull requests

2 participants