dotnet / dotnet/EntityFramework.Docs
Show more examples of obtaining and setting connection strings
- Dominant language
- Mermaid
- Stars
- 1.7k
- Forks
- 2k
- Avg merge
- 7d 23h
- Merged PRs (30d)
- 16
Description
What if I need to use a connection string from the config file? like, you know,
```
public ApplicationDbContext CreateDbContext(string[] args)
{
var builder = new DbContextOptionsBuilder();
builder.UseSqlServer( --> Configuration.GetConnectionString("DefaultConnection") <-- );
return new ApplicationDbContext(builder.Options);
}
```
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: 2fa64390-1232-8dd3-f170-7d5c68e29ad9
* Version Independent ID: 245bbba8-3102-4a66-15eb-650e05eb9e62
* Content: [Design-time DbContext Creation - EF Core](https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dbcontext-creation)
* Content Source: [entity-framework/core/miscellaneous/cli/dbcontext-creation.md](https://github.com/aspnet/EntityFramework.Docs/blob/master/entity-framework/core/miscellaneous/cli/dbcontext-creation.md)
* Product: **entity-framework**
* GitHub Login: @bricelam
* Microsoft Alias: **bricelam**
Contributor guide
Assessment
This issue has not been assessed yet.