Begining of implementing the entity framework
This commit is contained in:
parent
83f3c61661
commit
510b030fec
7 changed files with 108 additions and 43 deletions
15
Geekbot.net/Database/DatabaseContext.cs
Normal file
15
Geekbot.net/Database/DatabaseContext.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Geekbot.net.Database
|
||||
{
|
||||
public class DatabaseContext : DbContext
|
||||
{
|
||||
public DbSet<QuoteModel> Quotes { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
=> optionsBuilder.UseLoggerFactory(new LoggerFactory().AddConsole())
|
||||
// .UseInMemoryDatabase(databaseName: "Geekbot");
|
||||
.UseMySql(@"Server=localhost;database=geekbot;uid=geekbot;");
|
||||
}
|
||||
}
|
17
Geekbot.net/Database/QuoteModel.cs
Normal file
17
Geekbot.net/Database/QuoteModel.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
|
||||
|
||||
namespace Geekbot.net.Database
|
||||
{
|
||||
public class QuoteModel
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong UserId { get; set; }
|
||||
public string Quote { get; set; }
|
||||
public DateTime Time { get; set; }
|
||||
public string Image { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue