Asp Net Core: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
Zeile 23: | Zeile 23: | ||
dotnet new mvc -n Website -au Individual | dotnet new mvc -n Website -au Individual | ||
cd Website | cd Website | ||
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL | </pre> | ||
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL.Design | Zeile Hinzufügen in assappsettings.json | ||
<pre> | |||
"ConnectionStrings": { | |||
"PostgresConnection": "Host=localhost;Port=5432;Database=thorsten;Username=thorsten;Password=Test" | |||
}, | |||
</pre> | |||
Zeile Hinzufügen in ConfigureServices in program.cs | |||
<pre> | |||
var connectionString = builder.Configuration.GetConnectionString("PostgresConnection") ?? throw new InvalidOperationException("Connection string 'PostgresConnection not found."); | |||
builder.Services.AddDbContext<ApplicationDbContext>(options => | |||
options.UseNpgsql(connectionString)); | |||
</pre> | |||
<pre> | |||
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL | |||
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL.Design | |||
dotnet add package Microsoft.EntityFrameworkCore.Design | dotnet add package Microsoft.EntityFrameworkCore.Design | ||
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design | dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design |