You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Investigate possible issue with connection string or missing additional steps in .NET Core new db tutorial with SQLite #735
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.
ID: adb04585-f54b-70c0-e847-b044b388a4d5
Version Independent ID: 5e37f568-0621-a082-c75a-d2adf94dce8d
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.
@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?
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.
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.
Activity
Starkie commentedon Jun 2, 2018
We've tested it and apparently is related to how you execute the project:
dotnet runworks great.Microsoft.Data.Sqlite.SqliteExceptionwith the error messageSQLite Error 1: 'no such table: Blogs'./bin/debug/netcoreapp2.1and runningdotnet TestCoreApp.dllgives 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?
divega commentedon Jun 3, 2018
@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?
divega commentedon Jun 4, 2018
@davkean I am looking at this issue that seems
identicalrelated 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 runin the command line and in VS is ok.divega commentedon Jun 4, 2018
cc @BillHiebert as he changed this on dotnet/project-system#3073.
BillHiebert commentedon Jun 4, 2018
@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.
divega commentedon Jun 5, 2018
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.
EF Core: Additional instructions to run new database SQLite tutorial …