SQLProvider icon indicating copy to clipboard operation
SQLProvider copied to clipboard

I can't insert a row in a Postgresql table. I get a "Method 'System.Transactions.TransactionScope..ctor' not found."

Open laygr opened this issue 8 years ago • 7 comments
trafficstars

Description

I can't insert a row in a Postgresql table.

Repro steps

  1. Create an entity
  2. Submit changes

Like this:

let ctx = sql.GetDataContext()

let row = ctx.Public.MetaData.Create()

row.Indicator <- int64 10101010

ctx.SubmitUpdates()

Expected behavior

I expect the framework to insert a row in the database.

Actual behavior

I get this error:

System.MissingMethodException: Method 'System.Transactions.TransactionScope..ctor' not found. at FSharp.Data.Sql.Providers.PostgresqlProvider.FSharp-Data-Sql-Common-ISqlProvider-ProcessUpdates (System.Data.IDbConnection con, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] entities, FSharp.Data.Sql.Transactions.TransactionOptions transactionOptions) [0x0001e] in <595cce87de6dfdbfa745038387ce5c59>:0 at <StartupCode$FSharp-Data-SqlProvider>.$SqlRuntime.DataContext.f@1-44 (FSharp.Data.Sql.Runtime.SqlDataContext __, System.Data.IDbConnection con, Microsoft.FSharp.Core.Unit unitVar0) [0x00001] in <595cce87de6dfdbfa745038387ce5c59>:0 at FSharp.Data.Sql.Runtime.SqlDataContext.FSharp-Data-Sql-Common-ISqlDataContext-SubmitPendingChanges () [0x00024] in <595cce87de6dfdbfa745038387ce5c59>:0

Related information

  • Used database: Postgresql
  • Operating system: OS X Sierra
  • SQLProvider 1.1.5, from nuget
  • Mono with target framework: 4.6.1

laygr avatar Jul 07 '17 21:07 laygr

That's weird, why wouldn't Mono transactions work...

Can you try this: http://fsprojects.github.io/SQLProvider/core/odbc.html#DTC-Transactions

let ctx = sql.GetDataContext(
        { Timeout = TimeSpan.MaxValue; 
          IsolationLevel = Transactions.IsolationLevel.DontCreateTransaction
        })

Thorium avatar Jul 07 '17 21:07 Thorium

Sure... It didn't work neither:

System.MissingMethodException: Method 'System.Transactions.TransactionScope..ctor' not found. at FSharp.Data.Sql.Providers.PostgresqlProvider.FSharp-Data-Sql-Common-ISqlProvider-ProcessUpdates (System.Data.IDbConnection con, System.Collections.Concurrent.ConcurrentDictionary2[TKey,TValue] entities, FSharp.Data.Sql.Transactions.TransactionOptions transactionOptions) [0x0001e] in <595cce87de6dfdbfa745038387ce5c59>:0 at .$SqlRuntime.DataContext.f@1-44 (FSharp.Data.Sql.Runtime.SqlDataContext __, System.Data.IDbConnection con, Microsoft.FSharp.Core.Unit unitVar0) [0x00001] in <595cce87de6dfdbfa745038387ce5c59>:0 at FSharp.Data.Sql.Runtime.SqlDataContext.FSharp-Data-Sql-Common-ISqlDataContext-SubmitPendingChanges () [0x00024] in <595cce87de6dfdbfa745038387ce5c59>:0 at Db.insert () [0x001c1] in <5960032cc07a0b10a74503832c036059>:0 at [email protected] (Suave.Http+HttpRequest r) [0x00001] in <5960032cc07a0b10a74503832c036059>:0 at Microsoft.FSharp.Core.FSharpFunc2[T,TResult].InvokeFast[V] (Microsoft.FSharp.Core.FSharpFunc2[T,TResult] func, T arg1, TResult arg2) [0x00018] in <5939249c904cf4daa74503839c243959>:0 at Suave.Http.request[a] (Microsoft.FSharp.Core.FSharpFunc2[T,TResult] apply, Suave.Http+HttpContext context) [0x00001] in <5944f178748eb1aaa745038378f14459>:0 at [email protected] (Suave.Http+HttpContext context) [0x00001] in <5960032cc07a0b10a74503832c036059>:0 at Suave.WebPart+bind@14-5[a,b].Invoke (Microsoft.FSharp.Core.FSharpOption`1[T] _arg1) [0x00012] in <5944f178748eb1aaa745038378f14459>:0 at Microsoft.FSharp.Control.AsyncBuilderImpl+args@823-1[a,b].Invoke (a a) [0x00016] in <5939249c904cf4daa74503839c243959>:0

laygr avatar Jul 07 '17 21:07 laygr

Can you add reference to System.Transactions.dll? System.Transactions is used to ensure that if you have multiple updates to submit, they either success or fail totally, not partially.

Thorium avatar Jul 07 '17 23:07 Thorium

I'll try it. Give me a couple hours.

laygr avatar Jul 07 '17 23:07 laygr

I got the same error. Please let me know if you need me to try again with other configuration or if you need more info about my setup.

laygr avatar Jul 08 '17 03:07 laygr

Had similar issue with our Travis build server. Fixed when updated to Mono 5. Can you update to Mono 5?

Thorium avatar Jul 27 '17 11:07 Thorium

Adding a reference to System.Transactions.dll to your project could help.

Thorium avatar Sep 14 '17 11:09 Thorium