verdie-g / StoredProcedureEFCore

Entity Framework Core extension to execute stored procedures
MIT License
192 stars 44 forks source link

issue where connection is already open #15

Closed h0wXD closed 6 years ago

h0wXD commented 6 years ago

Hi @verdie-g

Could you have a look and see whether this causes any problems on your side. On my side I had exceptions thrown when the stored proc lib is used where a connection was already used before invoking the sp. Crashing with following error :

System.InvalidOperationException: The connection was not closed. The connection's current state is open.
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at StoredProcedureEFCore.StoredProcBuilder.OpenConnection() in C:\Git\gravitymain\StoredProcedureEFCore\StoredProcBuilder.cs:line 214
   at StoredProcedureEFCore.StoredProcBuilder.Exec(Action`1 action) in C:\Git\gravitymain\StoredProcedureEFCore\StoredProcBuilder.cs:line 87

Thanks a lot for this lib. It may be because it is being used in a project mixed with EF.

verdie-g commented 6 years ago

Hi,

Thanks for your PR. Someone once told me to make these checks, but I wasn't listening. Do you have any steps to reproduce? The connection is supposed to be closed after each stored procedures.