Add project files.
This commit is contained in:
28
StockDBEF/Models/StockDBContext.cs
Normal file
28
StockDBEF/Models/StockDBContext.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StockDBEF.Models
|
||||
{
|
||||
public class StockDBContext : DbContext
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public StockDBContext(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
public DbSet<Person> Persons { get; set; }
|
||||
public DbSet<StockMember> StockMembers { get; set; }
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
var connectionString = _configuration.GetValue<string>("ConnectionStrings:Stocks");
|
||||
optionsBuilder.UseSqlite(connectionString);
|
||||
//optionsBuilder.UseSqlite("Data Source=Facts.db");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user