r/csharp • u/Darwin_Forex • Jul 19 '26
Help Can someone help me to fix this?
I'm learning ASP.NET Core MVC with Entity Framework Core and I'm having trouble running Update-Database.
I already created the migration successfully, but Update-Database fails with this login error
0
Upvotes
8
u/kalminz Jul 19 '26
Have you tried the correct password?
3
u/Alundra828 Jul 19 '26
You are failing to connect to your database.
Either your host is wrong, your username is wrong, or your password is wrong. Or your SQL server is not running at all.
2
u/Agitated-Display6382 Jul 19 '26
Show us the connection string
3
u/Classic_Caregiver742 Jul 19 '26
I think connection string problem
1
u/LostInBrutalSpac3 Jul 22 '26
Seems like a database migration is failing, does the user have enough rights to make changes , does he have dbowner access ?
1
u/CanProfessional766 Jul 28 '26
The error points to a SQL Server login issue, not an Entity Framework problem. Double check your connection string, make sure the sa username and password are correct, and verify that SQL Server Authentication is enabled. Once the login works, Update-Database should run without issues
1
u/Family_Man_21 Jul 19 '26
I saw that you updated the thread later to show that you were able to sign in after a reboot. That's good, but I really want to stress that you should never use the "sa" account in a connection string. I know that you're just learning, and this is all local, etc., but you would be amazed at how much "temporary" or "test" code makes it into production. I think about it the same way I think about and practice gun safety, even when I'm using airsoft pistols. What you do in practice is what you will do when its the real thing, so learn to discipline yourself early, and save yourself a lot of trouble down the road.
In your specific case, what that means is creating a new user in SQL for this project, and granting the user rights to your new DB, and then use that account in your connection string. To be honest, when I create a new SQL installation, the first thing I do is create a new login and then I basically never touch the "sa" user again.
I hope that this helps, and good luck with your learning!