Search code examples
sql-serverentity-framework-coreef-code-first

How to tell what user "Integrated Security" is running as?


Running on my dev machine, connected to the db on another machine with this connection string in Visual Studio:

Data Source=dev-db,1433;Initial Catalog=MyDb;Persist Security Info=True;Integrated Security=True;Encrypt=True;TrustServerCertificate=True"

I'm connected, life is good. Trying to run the EF Core command Update-Database I get this error:

CREATE TABLE permission denied in database 'MyDb'

The question: what user is attempting to create the table and how do I figure that out? I know how to grant access on the db side, but knowing what user needs access is the mystery. I saw an answer here about a logon trigger, but that answer didn't seem to be a useful answer as it had no upvotes.


Solution

  • Integrated Security=True means to connect to SQL Server using Windows Integrated Auth using the identity of the user executing the program. So it's you.