dotnet / dotnet/EntityFramework.Docs

Document when PersistSecurityInfo=True is needed

Open
#2,926 4 comments 0 reactions 0 assignees View on GitHub
area-context-management area-migrations
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

## File a bug

When I pass to `UseSqlServer()` connection string, it connects to the docker db and local db. But when I pass to `UseSqlServer()` `new Microsoft.Data.SqlClient.SqlConnection(connString)`, it fails to connect to the docker db but connects to the local db. Simple repo https://github.com/umbarov/dotnet-sqlserver-gh-actions with Github Actions.

Connects to the docker db and local sql server:
```c#
var context = new AppDbContext(new DbContextOptionsBuilder().UseSqlServer(connString).Options);
```

Fails to connect to the docker db, but connects to the local sql server:
```C#
var context = new AppDbContext(new DbContextOptionsBuilder().UseSqlServer(new SqlConnection(connString)).Options);
```

### Include stack traces

```
Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user 'sa'.
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose
)
```

### Include provider and version information

EF Core version: 5.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5.0
Operating system: Windows 10 Pro , Version: 20H2, OS build: 19042.630

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.