EF Core returns exceptions after EnsureCreatedAsync

0

I noticed a strange output from EF Core at application first run (code first approach) after checking that the SQLite database was created.

There are two lines that begin with 'Exception thrown' and I'm trying to figure out the cause of these errors or at least their importance.

[19:41:57 DBG] Opening connection to database 'main' on server 'Test.db'.
'TestApp.exe' (CoreCLR: clrhost): Loaded 'C:\Users\Pavel\.nuget\packages\runtime.win-x64.microsoft.netcore.app\2.1.9\runtimes\win-x64\lib\netcoreapp2.1\System.Text.Encoding.dll'. Cannot find or open the PDB file.
Exception thrown: 'Microsoft.Data.Sqlite.SqliteException' in Microsoft.Data.Sqlite.dll
[19:41:57 DBG] An error occurred using the connection to database 'main' on server 'Test.db'.
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 14: 'unable to open database file'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteConnection.Open()
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
Exception thrown: 'Microsoft.Data.Sqlite.SqliteException' in Microsoft.EntityFrameworkCore.Relational.dll
[19:41:57 DBG] Opening connection to database 'main' on server 'Test.db'.
[19:41:57 DBG] Opened connection to database 'main' on server 'D:\...\bin\Debug\netcoreapp2.1\win-x64\Test.db'.

I get that information right after executing:

await context.Database.EnsureCreatedAsync(cancellationToken).ConfigureAwait(false);

It happens only at the first run and works fine after that (or I haven't noticed any problems yet).

Questions:

  • What is the 'main' database and why do I see it in the output when I just tried to connect to 'Test.db'?
  • Is it possible to get more detailed information about these exceptions? (e.g. stack trace)
entity-framework-core
ef-code-first
ef-core-2.0
asked on Stack Overflow Dec 21, 2019 by Pavel

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0