Kurse:Asp Net Core Übung 1: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| (2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
appsettings.json | |||
<pre> | |||
"ConnectionStrings": {"DefaultContext" : "Host=localhost;Port=5432;Database=thorsten;Username=thorsten;Password=Test" | |||
</pre> | |||
ApplicationDbContext | |||
<pre> | |||
public class ApplicationDbContext : DbContext | |||
{ | |||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext>options) | |||
:base (options) {} | |||
} | |||
</pre> | |||
Program.cs | Program.cs | ||
<pre> | <pre> | ||
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultContext"))); | builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultContext"))); | ||
</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")));