Libation/Source/_DB_NOTES.txt
2022-05-09 10:31:45 -04:00

42 lines
1.5 KiB
Plaintext

Migrations, quick
=================
View > Other Windows > Package Manager Console
Default project: DataLayer
Startup project: DataLayer
since we have mult contexts, must use -context:
Add-Migration MyComment -context LibationContext
Update-Database -context LibationContext
Startup project: reset to prev. eg: LibationWinForms
Migrations, detailed
====================
if only 1 context present, can omit -context arg:
Add-Migration MyComment
Update-Database
Migrations, errors
=================
if add-migration xyz throws and error, don't take the error msg at face value. try again with add-migration xyz -verbose
ERROR: Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program
SOLUTION: add nuget pkg: Microsoft.EntityFrameworkCore.Tools
SqLite config
=============
relative:
optionsBuilder.UseSqlite("Data Source=blogging.db");
absolute (use fwd slashes):
optionsBuilder.UseSqlite("Data Source=C:/foo/bar/blogging.db");
Logging/Debugging (EF CORE)
===========================
Once you configure logging on a DbContext instance it will be enabled on all instances of that DbContext type
using var context = new MyContext();
context.ConfigureLogging(s => System.Diagnostics.Debug.WriteLine(s)); // write to Visual Studio "Output" tab
//context.ConfigureLogging(s => Console.WriteLine(s));
see comments at top of file:
Dinah.EntityFrameworkCore\DbContextLoggingExtensions.cs