Kurse:Asp Net Core Übung 1: Unterschied zwischen den Versionen

Aus ahrensburg.city
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt)
Zeile 3: Zeile 3:
"ConnectionStrings": {"DefaultContext" : "Host=localhost;Port=5432;Database=thorsten;Username=thorsten;Password=Test"
"ConnectionStrings": {"DefaultContext" : "Host=localhost;Port=5432;Database=thorsten;Username=thorsten;Password=Test"
</pre>
</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")));