1

I am trying to build a small Web API that uses an Azure SQL Database. The database functionality is exposed via Stored Procedures and in order to call them, I am using Entity Framework for .NET, version 6.4.4 as it gives me access to the .edmx Data Model. I have properly configured the EF so that I can see the SPs and I've added one of them to my model. In my controller, I execute this piece of code:

var dbContext = new MyDbContext();
var result = dbContext.MyStoredProc();

I get an exception when the "MyStoredProc()" method gets called. The exception that is thrown is this:

enter image description here

For now, the connection string is configured to use SQL Authentication, so the user listed in the exception is the user that is configured in the connection string.

I can call the same SP no problems if I use SQL Server Management Studio, within a session open with the same user name and password as I have configured in the connection string.

Why is my application throwing up that exception? Are there specific privileges that I must elevate, in order for the connection to the database to be opened from my Web API?

Any help would be appreciated.

Cheers, Eddie

Eddie
  • 271
  • 4
  • 18
  • 1
    Pls check `connectionStrings` in `App.config`. For more details, you can check the post which name is [Timeout period elasped prior to obtaining a connection from the pool - Entity Framework](https://stackoverflow.com/questions/63062815/timeout-period-elasped-prior-to-obtaining-a-connection-from-the-pool-entity-fr/63069572#63069572). – Jason Pan Oct 07 '20 at 02:22
  • If there is any progress, please let me know so that it can help you better. – Jason Pan Oct 07 '20 at 02:24
  • @JasonPan You were right, there was a problem in the connection string. I checked it a million times, but somehow I missed that the password was misspelled. I wish I can mark your comment as the answer. – Eddie Oct 19 '20 at 22:45

1 Answers1

1

In projects that use Entity Framework, an error message usually reports that there is no Login failed for user. At this time, we need to check connectionStrings in ʻApp.config`.

In order to help more forum users, it is recommended that everyone can refer to the following tutorial.

Entity Framework Tutorial

Jason Pan
  • 15,263
  • 1
  • 14
  • 29