26 lines
861 B
C#
26 lines
861 B
C#
|
using Bunny.Dao.Entity.Blog;
|
|||
|
using Microsoft.EntityFrameworkCore;
|
|||
|
|
|||
|
namespace Bunny.Common.EFCore;
|
|||
|
|
|||
|
public class EfCoreContext : DbContext
|
|||
|
{
|
|||
|
public EfCoreContext()
|
|||
|
{
|
|||
|
// var dbPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "bunny.db");
|
|||
|
// DbPath = Path.Join(dbPath, "bunny.db");
|
|||
|
// DbPath = @"D:\Project\web\Bunny-Cli\template\CSharp\CSharp-Single-EFCore\Bunny.WebApi\bunny.db";
|
|||
|
var dataBaseConnection = AppSettings.GetAppConfig<string>("DataBase:DataBaseConnection");
|
|||
|
DbPath = dataBaseConnection;
|
|||
|
}
|
|||
|
|
|||
|
public DbSet<Blog> Blogs { get; set; }
|
|||
|
public DbSet<Post> Posts { get; set; }
|
|||
|
|
|||
|
public string DbPath { get; }
|
|||
|
|
|||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
|||
|
{
|
|||
|
options.UseSqlite($"Data Source={DbPath}");
|
|||
|
}
|
|||
|
}
|