asynkron / protoactor-dotnet-contrib

Contributions for ProtoActor .NET
http://proto.actor
Apache License 2.0
3 stars 2 forks source link

InvalidOperationException always thrown by SqlServerProvider constructor if autoCreateTables parameter is set to true #5

Open UniSnake opened 4 years ago

UniSnake commented 4 years ago

Expected Behavior

No exception.

Actual Behavior

System.InvalidOperationException: 'ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.'

Steps to Reproduce the Problem

Pass true to SqlServerProvider constructor for example: services.AddSingleton<IProvider>(new SqlServerProvider(connectionString, false, "Actors"));

Specifications

StackTrace

``` at System.Data.SqlClient.SqlCommand.ValidateCommand(Boolean async, String method) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Proto.Persistence.SqlServer.SqlServerProvider.ExecuteNonQuery(String sql) at Proto.Persistence.SqlServer.SqlServerProvider.CreateSnapshotTable() at Proto.Persistence.SqlServer.SqlServerProvider..ctor(String connectionString, Boolean autoCreateTables, String useTablesWithPrefix, String useTablesWithSchema) ```

Recommendation

Add line connection.Open() to SqlServerProvider.ExecuteNonQuery(string).

UniSnake commented 4 years ago

Ah, I see there is already a PR for this (https://github.com/AsynkronIT/protoactor-dotnet-contrib/pull/4)