首页 > 解决方案 > F# MySQL 类型提供程序,参考/包,Linux Monodevelop

问题描述

我正在将一个项目(和数据库)从 Windows、SQL Server 和 Visual Studio 转移到 Linux Mint、MySQL 和 MonoDevelop。我已经完成了大部分工作——但我无法让 MySQL 的类型提供程序工作。最明显的症结似乎是:

open FSharp.Data.Sql

给出错误,“Sql”的命名空间未定义。(而且我没有看到该名称的 NuGet 包。)

以下任何一项都没有错误:

open MySql.Data    
open MySqlConnector
open FSharp.Data

我似乎有包/参考:

MySqlConnector
MySql.Data
FSharp.Data
FSharp.Data.SqlClient
FSharp.Data.TypeProviders

然后我也收到一个错误:

SqlDataProvider

“未定义类型'SqlDataProvider'”。

我确信这很简单,但我不擅长使用参考资料或如何使用参考资料——抱歉,谢谢。

(而且我真的不明白如何区分SQLProvider提供FSharp.Data.SqlMySql.Data.dllMySqlConnector.dll......)

编辑:感谢您的提问。我假设这是 .Net Framework,而不是 Core。该项目起源于大约 3 年前的默认 Visual Studio 模板,而我从来没有做过任何事情来增加 Core。

对于 fsproj 文件——我不确定是什么。我在解决方案中有 4 个项目(只有 2 个正在使用中)。对于具有类型提供程序类型的项目,这是 /obj/Debug 中的 project.fsproj.FileListAbsolute.txt。

C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/Library3.XML
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/Library3.exe
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/Library3.pdb
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/FSharp.Core.dll
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/FSharp.Data.TypeProviders.dll
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/FSharp.Core.xml
C:/Users/gen/Desktop/Simulations/SqlFunctions/bin/Debug/FSharp.Data.TypeProviders.xml
C:/Users/gen/Desktop/Simulations/SqlFunctions/obj/Debug/Library3.exe
C:/Users/gen/Desktop/Simulations/SqlFunctions/obj/Debug/Library3.pdb
/home/gen/Downloads/Simulations 2018-07-29/SqlFunctions/bin/Debug/Library3.XML
/home/gen/Downloads/Simulations 2018-07-29/SqlFunctions/obj/Debug/SqlFunctions.fsprojResolveAssemblyReference.cache
/home/gen/Downloads/Simulations 2018-07-29/SqlFunctions/obj/Debug/Library3.exe
/home/gen/Downloads/Simulations 2018-07-29/SqlFunctions/obj/Debug/Library3.pdb

其中上半部分看起来像旧的 Windows 参考资料——?显然,其中没有一个包含像 MySql.Data 这样的东西——它确实出现在项目/参考/来自包中。

哦等等,这在解决方案级别可能更相关(我从未使用过 .fsproj 文件):

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>397e58f9-3730-4c45-a36f-7c9f64d94f1d</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <RootNamespace>Simulations</RootNamespace>
    <AssemblyName>Simulations</AssemblyName>
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
    <TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <Name>Simulations</Name>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <Tailcalls>false</Tailcalls>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <WarningLevel>3</WarningLevel>
    <DocumentationFile>bin\Debug\Simulations.XML</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <Tailcalls>true</Tailcalls>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <WarningLevel>3</WarningLevel>
    <DocumentationFile>bin\Release\Simulations.XML</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup>
    <MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
  </PropertyGroup>
  <Choose>
    <When Condition="'$(VisualStudioVersion)' == '11.0'">
      <PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
        <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
      </PropertyGroup>
    </When>
    <Otherwise>
      <PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
        <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
      </PropertyGroup>
    </Otherwise>
  </Choose>
  <Import Project="$(FSharpTargetsPath)" />
  <ItemGroup>
    <Compile Include="AssemblyInfo.fs" />
    <Compile Include="1a.fs" />
    <Compile Include="2a.fs" />
    <Compile Include="2b.fs" />
    <Compile Include="2c.fs" />
    <Compile Include="2d.fs" />
    <Compile Include="2e.fs" />
    <Compile Include="2f.fs" />
    <Compile Include="3a.fs" />
    <Compile Include="3b.fs" />
    <Compile Include="3c.fs" />
    <Compile Include="3d.fs" />
    <Compile Include="4a.fs" />
    <Compile Include="4b.fs" />
    <Compile Include="4c.fs" />
    <Compile Include="5a.fs" />
    <Compile Include="5b.fs" />
    <Compile Include="5c.fs" />
    <Compile Include="5d.fs" />
    <Compile Include="5e.fs" />
    <Compile Include="6a.fs" />
    <Compile Include="6b.fs" />
    <Compile Include="7a.fs" />
    <None Include="Script.fsx" />
    <None Include="packages.config" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="mscorlib" />
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Data.Linq" />
    <Reference Include="System.Numerics" />
    <Reference Include="FSharp.Core">
      <HintPath>packages\FSharp.Core.4.5.2\lib\net45\FSharp.Core.dll</HintPath>
    </Reference>
    <Reference Include="FSharp.Data.TypeProviders">
      <HintPath>packages\FSharp.Data.TypeProviders.5.0.0.6\lib\net40\FSharp.Data.TypeProviders.dll</HintPath>
    </Reference>
    <Reference Include="System.ValueTuple">
      <HintPath>packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="SqlFunctions\SqlFunctions.fsproj">
      <Name>SqlFunctions</Name>
      <Project>{14eefa95-3b68-4348-a7de-db29bfb3567f}</Project>
      <Private>True</Private>
    </ProjectReference>
  </ItemGroup>
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

再次感谢。

编辑2:正如我在下面评论的那样 - 情况已经发展(我认为):当阅读器关闭时尝试读取无效 - 类型声明错误。

标签: mysqllinuxf#monodeveloptype-providers

解决方案


推荐阅读