Jeśli masz ochotę to postaw kawę, będzie to motywacja do kolejnej pracy https://buycoffee.to/emilcsharp
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Noter
{
internal class AppDbContext:DbContext
{
private readonly string sciezkaNotera = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"Noter");
private readonly string sciezka;
public AppDbContext()
{
// Tworzenie katalogu, jeśli nie istnieje
Directory.CreateDirectory(sciezkaNotera);
// Pełna ścieżka do pliku bazy danych
sciezka = Path.Combine(sciezkaNotera, "noter.db");
this.Database.EnsureCreated();
}
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source={sciezka}");
public DbSet<notatka> notatki { get; set; }
}
}
Komentarze
Prześlij komentarz