Versatile OpenID Connect stack for ASP.NET Core and Microsoft.Owin (compatible with ASP.NET 4.6.1)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
1.2 KiB

#if NET
using Microsoft.EntityFrameworkCore;
#else
using System.Data.Entity;
using SQLite.CodeFirst;
#endif
namespace OpenIddict.Sandbox.Console.Client.Models;
public class ApplicationDbContext : DbContext
{
#if NET
public ApplicationDbContext(DbContextOptions options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.UseOpenIddict();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite($"Filename={Path.Join(Path.GetTempPath(), "openiddict-sandbox-console-client.sqlite3")}");
}
#else
public ApplicationDbContext()
: base("name=DefaultConnection")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.UseOpenIddict();
// Override the default database initializer to use the one provided
// by SQLite.CodeFirst, which automatically creates the database.
Database.SetInitializer(new SqliteCreateDatabaseIfNotExists<ApplicationDbContext>(modelBuilder));
}
#endif
}