All checks were successful
Build and Push Docker Image / docker (push) Successful in 48s
20 lines
805 B
C#
20 lines
805 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Design;
|
|
|
|
namespace Example.Data;
|
|
|
|
public sealed class SqliteApplicationDbContextFactory : IDesignTimeDbContextFactory<SqliteApplicationDbContext>
|
|
{
|
|
public SqliteApplicationDbContext CreateDbContext(string[] args)
|
|
{
|
|
var configuration = DesignTimeConfiguration.Create(includeDevelopmentSettings: true);
|
|
var connectionString = configuration.GetConnectionString("DefaultConnection")
|
|
?? throw new InvalidOperationException("Connection string 'DefaultConnection' was not found.");
|
|
|
|
var optionsBuilder = new DbContextOptionsBuilder<SqliteApplicationDbContext>();
|
|
optionsBuilder.UseSqlite(connectionString);
|
|
|
|
return new SqliteApplicationDbContext(optionsBuilder.Options);
|
|
}
|
|
}
|