添加了标识查询
This commit is contained in:
17
BITKit/Scripts/EntityFramework/SQLiteContext.cs
Normal file
17
BITKit/Scripts/EntityFramework/SQLiteContext.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BITKit;
|
||||
|
||||
public class SqlLiteContext<T> : DbContext where T : class
|
||||
{
|
||||
private const string _database = "Database";
|
||||
public DbSet<T> context { get; private set; }
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
PathHelper.GetFolderPath(_database);
|
||||
var path = PathHelper.GetPath(_database, $"{typeof(T).Name}.db");
|
||||
var sql = $"Data Source={path}";
|
||||
BIT4Log.Log<T>($"已创建数据库链接:{path}");
|
||||
optionsBuilder.UseSqlite(sql);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user