mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-19 16:06:36 +08:00
完善各层
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
|
||||
namespace Yi.Framework.Model.Models
|
||||
{
|
||||
public class DataContext : DbContext
|
||||
{
|
||||
private readonly IOptionsMonitor<SqliteOptions> _optionsMonitor;
|
||||
private readonly string _connStr;
|
||||
|
||||
public DataContext(IOptionsMonitor<SqliteOptions> optionsMonitor)
|
||||
{
|
||||
_optionsMonitor = optionsMonitor;
|
||||
_connStr = _optionsMonitor.CurrentValue.Url;
|
||||
}
|
||||
|
||||
public DataContext(string connstr)
|
||||
{
|
||||
_connStr = connstr;
|
||||
}
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
optionsBuilder.UseSqlite(_connStr);
|
||||
}
|
||||
}
|
||||
//public virtual DbSet<TbBrand> TbBrand { get; set; }
|
||||
}
|
||||
}
|
||||
17
Yi.Framework/Yi.Framework.Model/Models/user.cs
Normal file
17
Yi.Framework/Yi.Framework.Model/Models/user.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Model.Models
|
||||
{
|
||||
public class user
|
||||
{
|
||||
[Key]
|
||||
public int id { get; set; }
|
||||
public string name { get; set; }
|
||||
public int age { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user