Skip to content

Commit 17125a2

Browse files
Move Sample app connection string to configuration file (#621)
1 parent c94a149 commit 17125a2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

net/Sample/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static void Main(string[] args) {
2020
.AddEntityFrameworkSqlServer()
2121
.AddDbContext<NorthwindContext>(options => options
2222
//.UseSqlServer("Server=.\\SQLEXPRESS; Database=Northwind; Trusted_Connection=True")
23-
.UseSqlServer("Data Source=(localdb)\\MSSQLLocalDB; Database=Northwind; Integrated Security=True; MultipleActiveResultSets=True; App=EntityFramework")
23+
.UseSqlServer(builder.Configuration.GetConnectionString("NorthwindConnectionString"))
2424
);
2525

2626
var app = builder.Build();

net/Sample/appsettings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ConnectionStrings": {
3+
"NorthwindConnectionString": "Data Source=(localdb)\\MSSQLLocalDB; Database=Northwind; Integrated Security=True; MultipleActiveResultSets=True; App=EntityFramework",
4+
"NorthwindConnectionStringIis": "Data Source=.; Database=Northwind; User Id=; Password=; MultipleActiveResultSets=True; App=EntityFramework; TrustServerCertificate=True"
5+
}
6+
}

0 commit comments

Comments
 (0)