Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views1 page

PRN

The document outlines steps for setting up Entity Framework Core with a SQL Server database, including adding necessary packages and configuring the connection string. It also describes how to scaffold a DbContext from an existing database. Additionally, it demonstrates how to load configuration settings from a JSON file for database connection management.

Uploaded by

phanduonghuy2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

PRN

The document outlines steps for setting up Entity Framework Core with a SQL Server database, including adding necessary packages and configuring the connection string. It also describes how to scaffold a DbContext from an existing database. Additionally, it demonstrates how to load configuration settings from a JSON file for database connection management.

Uploaded by

phanduonghuy2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

dotnet ef migrations add "Initial"

dotnet ef database update


dotnet add package Microsoft.EntityFrameworkCore.Sqlite
dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.Tools
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
"ConnectionStrings": {
"DefaultConnection": "Server=LAPTOP-
I179J3VF;Database=SampleL2;Trusted_Connection=True;TrustServerCertificate=True;"
}
builder.Services.AddDbContext<AppDbContext>(options =>

options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")
));

db first
dotnet ef dbcontext scaffold " Data Source=LAPTOP-I179J3VF;Database=SampleL2;User
TrustServerCertificate=true;Trusted_Connection=SSPI;Encrypt=false;"Microsoft.Entity
FrameworkCore.SqlServer --output-dir Models

Scaffold-DbContext "Server=LAPTOP-
I179J3VF;Database=FootballFieldBooking;Trusted_Connection=True;TrustServerCertifica
te=true;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir -Context AppDbContext
bo vo trong confi

var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();


if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlServer(config.GetConnectionString("MyStockDB"));
}

data

You might also like