André Claudino
André Claudino

Reputation: 588

Can't Compile using SqlDataConnection in F# on Mono in Linux

I am using mono on Linux, making an F# code to access an SQL Server Database. I am using SqlDataConnection.

My code is the following:

namespace AggregatorService

open FSharp.Data.TypeProviders
open System.Data
open System.Data.Linq

module DataBaseProvider = 

    type databaseConn = SqlDataConnection<ConnectionString = "Data Source=10.0.40.11;Initial Catalog=master;Persist Security Info=True;User ID=sa;Password=xxxxx">

    let getDataContext() =
        let dbConn = databaseConn.GetDataContext();
        dbConn

I can't compile this code. I am getting this annoying error:

The type provider 'FSharp.Data.TypeProvider.DesignTime.DataProviders' reported an error reading schema. No access to the given key (FIS3033)

My package.config file is:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Deedle" version="1.2.5" targetFramework="net40" />
  <package id="FSharp.Core" version="4.0.0.1" targetFramework="net40" />
  <package id="FSharp.Data" version="2.3.2" targetFramework="net40" />
  <package id="FSharp.Data.SqlClient" version="1.8.2" targetFramework="net40" />
  <package id="FSharp.Data.TypeProviders" version="5.0.0.2" targetFramework="net40" />
  <package id="NUnit" version="2.6.4" targetFramework="net40" />
  <package id="SQLProvider" version="1.0.22" targetFramework="net40" />
</packages>

A C# program is connecting from the same computer, so, I think the problem is not with mono configurations or to be in a Linux machine.

Anyone has a solution or a Tip on how to solve that?

Upvotes: 1

Views: 178

Answers (1)

Andr&#233; Claudino
Andr&#233; Claudino

Reputation: 588

Unfortunatelly it looks mono is not able to deal this package as well I wish. Searching I found there is a bug from two years ago, but I don't find any solution yet.

What I am doing to leave that is using FSharp.Data.Sql instead, then, I use SqlDataProvider instead of SqlDataConnection, ow it looks:

namespace AggregatorService

open FSharp.Data.Sql open Deedle open System.Linq

module DatabaseService =

[<Literal>]
let connectionString = "Data Source=10.0.40.11;Initial Catalog=nextel_ericsson_umts_brasil;Persist Security Info=True;User ID=sa;Password=****";

type bd = SqlDataProvider<
            ConnectionString = connectionString,
            DatabaseVendor = Common.DatabaseProviderTypes.MSSQLSERVER >

type Database() =

    static member contextDbo() =
        bd.GetDataContext().Dbo

    static member acAgregations() =
        Database.contextDbo().AcAgregations |> Frame.ofRecords

    static member acBusyHourDefinition() =
        Database.contextDbo().AcBusyHourDefinition
        |> Frame.ofRecords
        //|> Frame.getCols["time_agregation_type", "destination_table", "reference_table", "alternative_reference_table_scan", "formula"]

    static member acBusyHourDefinitionFilterByTimeAgregationTipe(value:int) = 
        Database.acBusyHourDefinition()
        |> Frame.indexRowsInt "tome_agregation_type"
        |> Frame.getRows
        |> Frame.filterRowValues( fun row -> row.GetAs<string list>)

As I can see, that works the same way. I don't know if there is some difference expected, but it's dealing with my needs until now.

Upvotes: 2

Related Questions