Skip to content

Investigate possible issue with connection string or missing additional steps in .NET Core new db tutorial with SQLite #735

Closed

Description

@divega

I got a report saying that if you follow this instructions migrations commands will create a database on the root folder but then execution will try to look for the database file in bin\debug, which will make the application crash.


Document Details

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

Activity

  1. Starkie commented on Jun 2, 2018

    @Starkie

    We've tested it and apparently is related to how you execute the project:

    • Executing the project from a powershell console using dotnet run works great.
    • Executing the project from visual studio doesn't work. Throwing a Microsoft.Data.Sqlite.SqliteException with the error message SQLite Error 1: 'no such table: Blogs'.
    • Similarly, entering the /bin/debug/netcoreapp2.1 and running dotnet TestCoreApp.dll gives the same error.

    It seems to be an inconsistency in the way dotnet and visual studio handle the local working directory. So... Changing it from the Project Settings > Debug > Working Directory and setting the path to the root of the project, makes it work again.

    Should the tutorial be updated?

  2. divega commented on Jun 3, 2018

    @divega
    ContributorAuthor

    @Starkie well, we could add a note to the walkthrough saying that if you choose to use VS, you can set the working directory manually to be the root of the project, but the truth is that the whole walkthrough currently only covers the instructions for building the app using the command-line tools, so not sure how much value there is in mentioning VS just for this.

    Anyway, I agree there is an inconsistency in the working directory between what you get using dotnet command-line and VS, and I am trying to figure out the right place to report it (I doubt it is by-design).

    @DamianEdwards does this ring any bells? Any suggestion on where to report it?

  3. divega commented on Jun 4, 2018

    @divega
    ContributorAuthor

    @davkean I am looking at this issue that seems identical related to dotnet/project-system#2239:

    If you run a console app from the command line (that is, with 'dotnet run), the working directory is the project directory, if you run from VS, the default working directory is the output directory (i.e. bin\debug\netcoreapp2.1`). This is important in this case because there is a database file that needs to be in the right location.

    But that one is supposed to be fixed already. Is there a known change/regression in 2.1 or do you want me to report it?

    After re-reading dotnet/project-system#2239, it seems this was changed intentionally. What I don't get is why we think the inconsistency between dotnet run in the command line and in VS is ok.

  4. divega commented on Jun 4, 2018

    @divega
    ContributorAuthor

    cc @BillHiebert as he changed this on dotnet/project-system#3073.

  5. self-assigned this
    on Jun 4, 2018
  6. BillHiebert commented on Jun 4, 2018

    @BillHiebert

    @Pilchie - I made the change, but I wasn't the driver for it. If I recall, it was to be consistent with the full framework console project.

  7. divega commented on Jun 5, 2018

    @divega
    ContributorAuthor

    Thanks @BillHiebert, @Pilchie, @davkean. I went ahead and created dotnet/project-system#3619 on your side.

    I will keep this documentation issue open to decide how/if to update the docs after the outcome of dotnet/project-system#3619 is known.

    Note to self: the article contains a note that talks about paths in the connection string being relative to the output path, which supposedly became obsolete in 2.0, but may have become relevant again.

  8. added this to the 2.2.0 milestone on Jun 13, 2018
  9. added a commit that references this issue on Sep 27, 2018
    f3aae60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions