Merge Common to Desktop
This commit is contained in:
parent
26915defe1
commit
e9c6e14965
40 changed files with 447 additions and 282 deletions
27
app/InkForge.Desktop/Data/NoteDbContextFactory.cs
Normal file
27
app/InkForge.Desktop/Data/NoteDbContextFactory.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using InkForge.Desktop.Services;
|
||||
using InkForge.Data;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
using SmartFormat;
|
||||
|
||||
namespace InkForge.Desktop.Data;
|
||||
|
||||
public class NoteDbContextFactory(WorkspaceContext context, IConfiguration configuration) : IDbContextFactory<NoteDbContext>
|
||||
{
|
||||
private string? _connectionString;
|
||||
|
||||
public NoteDbContext CreateDbContext()
|
||||
{
|
||||
_connectionString ??= Smart.Format(configuration.GetConnectionString("DefaultConnection")!, new
|
||||
{
|
||||
WorkspaceFile = context.DbPath
|
||||
});
|
||||
|
||||
DbContextOptionsBuilder<NoteDbContext> builder = new();
|
||||
builder.UseSqlite(_connectionString, o => o.MigrationsAssembly("InkForge.Sqlite"));
|
||||
|
||||
return new NoteDbContext(builder.Options);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue