Begining of implementing the entity framework

This commit is contained in:
Runebaas 2018-05-09 01:21:39 +02:00
parent 83f3c61661
commit 510b030fec
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
7 changed files with 108 additions and 43 deletions

View 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;");
}
}

View 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; }
}
}