Kurse:Asp Net Core Übung 1: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 10: | Zeile 10: | ||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext>options) | public ApplicationDbContext(DbContextOptions<ApplicationDbContext>options) | ||
:base (options) {} | :base (options) {} | ||
} | } | ||
</pre> | </pre> | ||
Aktuelle Version vom 17. Juli 2025, 01:38 Uhr
appsettings.json
"ConnectionStrings": {"DefaultContext" : "Host=localhost;Port=5432;Database=thorsten;Username=thorsten;Password=Test"
ApplicationDbContext
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext>options)
:base (options) {}
}
Program.cs
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultContext")));