Created
October 31, 2021 20:57
-
-
Save Guifgr/3a3addad290322b98d21c4d183832929 to your computer and use it in GitHub Desktop.
sqlite entity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ChatMessageServer.Model; | |
using Microsoft.EntityFrameworkCore; | |
namespace ChatMessageServer.Database | |
{ | |
public class Context : DbContext | |
{ | |
public Context() | |
{ | |
Database.EnsureCreated(); | |
} | |
public DbSet<ChatMessage> ChatMessages { get; set; } | |
protected override void OnConfiguring(DbContextOptionsBuilder options) | |
{ | |
options.UseSqlite("Data Source=Messages.db"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await using var context = new Context(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment