質問

I've been searching for an example on how to connect to a MySql database and use F# type providers but I could not find anything online.

Can anyone give me a clue? What - if any - extra packages do I need? Do I use SqlDataConnection or SqlEntityConnection.

Excuse my ignorance but I'm totally lost. Any and all help is appreciated. I love the idea of type providers and have a fair amount of experience with functional programing but it's the setup around this that gets me.

役に立ちましたか?

解決

I don't think there is out-of-the box type provider that would work with MySQL at the moment. However, Ross McKinlay has been working on a better type provider for SQL databases (more generally). It currently works with MS SQL server and SQL Lite.

It should be possible to write an extension to support MySQL with fairly small amount of work (but sadly, it has not been done yet). See his blog for details. I'm sure that contributions are welcome!

他のヒント

I haven't tested this, but if Entity Framework works with MySql (it does) and if F# has an Entity Framework Type Provider (it does) then I would expect the Entity Framework Type Provider to work with MySql.

Have you tried that approach?

If you are still interested, I recently added support for MySQL to my SQL type provider, help with testing would be good!

A general SQL database type provider, supporting LINQ queries, schema exploration, individuals and much more besides.

The provider currently supports MS SQL Server, SQLite, PostgreSQL, Oracle, MySQL and MS Access. All database vendors except SQL Server and MS Access will require 3rd party ADO.NET connector objects to function. These are dynamically loaded at runtime so that the SQL provider project is not dependent on them. You must supply the location of the assemblies with the "ResolutionPath" static parameter.

https://fsprojects.github.io/SQLProvider/

I think I actually got it to work!! Here's what I did:

  • Installed the MySql Connector
  • Added to and referenced MySql.Data & MySql.Data.Entity in my project
  • Added and EntityFramework 5.0 to my project
  • Added both MySql.Data & MySql.Data.Entity to the GAC.

Then I was able to use SqlEntityConnection and get the types!

There's gotta be an easier way to do this though. I particular, adding stuff to the GAC should not be a part of all this process. I mean, am I asking to much for this to work pretty much "out of the box"?!

Unfortunately, I'm extremely unfamiliar with .Net yet, so I couldn't get the whole thing working with the App.config file. Based on my searches here, it looks like I'm not the only one having troubles with this. If anyone has any feedback/suggestions please help!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top