Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Core MySql

I've just started coding in Visual Studio Code with .NET Core, on Ubuntu 14.04.4 I'm used to both using Ubuntu (from personal interests, hobby, etc) and .NET and Visual Studio at work.

But I've run into a problem i can't seem to overcome. I'm building a small console app that i want to communicate with a MySql Server, but I can't seem to get the MySql.ConnectorNET.Data working properly.

It was installed with the command dnu install MySql.ConnectorNET.Data And that seemed to work fine. The dependency was added in the project.json file, and intellisense was able to traverse the package just fine, but the OmniSharp Log reports that:

[INFORMATION:OmniSharp.Dnx.DnxProjectSystem] Project /home/<username>/VSCode/SimpleSQLatmpt/project.json has these unresolved references: MySql.ConnectorNET.Data

and I simply can't seem to fix that. VSCode seems to detect it, and asks me to run the dnu restore command. But it's to no avail. For all intends and purposes it seems like MySql.ConnectorNET.Data is available in the project, but just can't be used.

Can any one tell me how to fix this? And just as important, why it is happening in the first place?

Thank you very much for your time.

like image 700
rasmus91 Avatar asked Mar 08 '16 10:03

rasmus91


People also ask

Can I use MySQL with .NET Core?

NET Core and MySQL are both free and open source technologies. The new ASP.NET Core can run on Linux and in Linux Containers, and MySQL is one of the easiest databases to get started with. This makes the combination of ASP.NET Core and MySQL a pretty compelling combination.

Does .NET support MySQL?

Connector/NET includes full support for: Features provided by MySQL Server, up to and including the MySQL 8.0 release series. MySQL as a document store (NoSQL), along with X Protocol connection support to access MySQL data using X Plugin ports.

How do I connect MySQL database to dotnet core?

Go to File -> New Project -> Select Web from templates->choose ASP.NET Core Web Application (. NET Core). Provide the name for the Web app and click OK. Select the Web Application template and click OK.

Which database is best for .NET Core?

SQL Server is the most popular database when talking about ASP.NET Core since it's what Microsoft is also selling and also the first one that Entity Framework Core is developed for. It's not free mind you. You can now use SQL Server in Linux as Microsoft has developed a Linux version that you can use.


1 Answers

At the time of this question (Mar 2016) there was no .NET Core-compatible ADO.NET provider for MySQL.

Now situation is changed:

  • MySqlConnector written by Bradley Grainger -- licensed under MIT, and offers full async support
  • MySql.Data (>6.10) provided by Oracle (traditionally, GPL)

Personally I prefer MySqlConnector -- it can be used in commercial projects for free (MIT license); also I've tested it with my NReco.Data library under Linux, and it works perfectly in my scenarious. Unfortunately, MySqlConnector doesn't support EF Core yet.

--- UPDATE --

One more .NET Core-compatible MySQL connector + EF Core MySQL provider:

  • Pomelo.Data.MySql (unfortunately it doesn't implement true async behaviour)
  • Pomelo.EntityFrameworkCore.MySql
like image 170
Vitaliy Fedorchenko Avatar answered Sep 22 '22 00:09

Vitaliy Fedorchenko