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.
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
UPDATE 2
MySql Connector NET for .NET Core 1.0 was just released (Sep 2016)
http://insidemysql.com/mysql-connector-net-for-net-core-1-0/
I didn't try Bradley Grainger's connector, but this one from MySQL do not support SSL. :(
So, anybody who wants to use anyway, should connect with ";SslMode=None;" in the connection string.
Related
I've added the latest .Net Provider for DB2 to my project. It seems to add half of IBM's source to my project :|
Seriously, there is an almost 80MB clidriver folder in there now. I'm assuming IBM still hasn't gotten around to making this provider fully managed after 20 years.
Do I need this folder when I deploy the code? What about for .Net Core? Do I need to build it separately for Linux?
The docs aren't great on what this is for.
I’ve been recruited onto a project to modify an existing microservice thats’s written in C# and that runs in a Linux env—CentOS flavor. Presently it persists data as JSON in a key-value store. My task is to reimplement the persistence to use PostgreSQL and an appropriate representation for ordinary SQL manipulation—table(s) with primitive, scalar column datatypes.
So I need a PostgreSQL driver for C#. Preliminary research points to Npgsql as the preferred choice.
It seems that I need to install .NET Core first and that this will provide me with: (1) the env to compile and execute a plain “Hello World” C# terminal app; and (2) the env into which I can install Npgsql. (A terminal app is all I need for now.)
Am I right so far? Or have I gone wrong already?
Googling for “Download .NET Core for Linux” took me HERE. The site says “Ubuntu 19.04 Package Manager - Install .NET Core”. And the install steps use “dpkg” and “apt-get”. These are Debian-only tools. (I understand that Ubuntu is based on Debian.)
Obviously, I can create an Ubuntu VM for my prototype work. (I’ll use Parallels on my MacBook.) But I’d prefer to use CentOS. I’ve read that CentOS, like Ubuntu, is forked from Debian. So, before I risk wasting time:
Has anybody installed .NET Core for Linux on CentOS and then written a C# app that does SQL to a PostgreSQL database?
You are on the right path. .NET Core will run on Linux (CentOS or Ubuntu). Npgsql is a .NET Core-compatible library that will run anywhere where .NET Core runs (Linux, Windows, MacOS). Once you properly install .NET Core, use any IDE to create a sample Hello World application (Visual Studio for Mac or Jetbrains Rider are good options). At that point you can add the latest Npgsql Nuget package and try out the getting started code sample from the docs.
Has anybody installed .NET Core for Linux on CentOS and then written a C# app that does SQL to a PostgreSQL database?
I installed the .Net Core on a CentOS 7 and used Npgsql to connect to my PostgreSql Db, and it works just as good as with any other database and connector.
It seems that I need to install .NET Core first and that this will provide me with: (1) the env to compile and execute a plain “Hello World” C# terminal app; and (2) the env into which I can install Npgsql. (A terminal app is all I need for now.)
Am I right so far? Or have I gone wrong already?
That is right so far. I have gone through the same process with a Centos 7 and it works perfectly. To install the .Net core SDK and the .Net core runtime on CentOS you can follow the instructions on the following MSDN link. It is targeting CentOS 7 but the command are sufficiently generic to work directly or with little adaptation effort to a nearby version.
Basically you can run the following commands and you will be done with this part
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
(To register the product key, repository and install required dependencies)
sudo yum install dotnet-sdk-3.1
(To install .Net Core SDK)
sudo yum install aspnetcore-runtime-3.1
(To install Asp.net Core runtime)
sudo yum install dotnet-runtime-3.1
(To install .Net core runtime)
At this step you can use a simple HelloWorld-Like terminal app in which you would add a reference to the Npgsql library using (for example)
dotnet add package Npgsql --version 4.1.2
Your app project will then reflect this change with a package reference tag like:
<ItemGroup>
<PackageReference Include="Npgsql" Version="4.1.2" />
</ItemGroup>
After this step you can configure a database connection string and use the Npgsql data access classes to connect to your database and perform various operations. You could use for instance the link provided by Shay Rojansky for this purpose.
If your .Net core and your Npgsql package are correctly installed, any other issues you could meet would probably be related to
Importing the right namespaces
Ident authentication failures (which could be solved by rightly configuring pg_hba.conf)
I've installed Visual Studio Code on Debian 9.9 with .Net Core 2.0. Using the mssql package, I've been able to query a SQL Server database running in Docker on the same machine. However, when I try to use System.Data.SqlClient to query the database in a C# console application, I keep getting errors saying that SqlConnection and SqlCommand are deprecated and that I need to use System.Data.SqlClient version 0.0.0.0. I can't find that version (I was pretty sure it didn't exist when I saw the message), so I'm wondering if maybe there's some kind of weird configuration thing that I don't know. If anyone else has had this issue and figured out a solution, would you mind sharing how to fix it?
This is obviously an old question, but in case someone else stumbles upon it:
You need to add the package to your project. You can do this in VS Code by using the terminal, and entering the command dotnet add package System.Data.SqlClient
When I try to connect MySQL (8.0) database with Visual Studio 2018 I get this error message
"Authentication method 'caching_sha2_password' not supported by any of the available plugins"
Also I am unable to retrieve Database name.
I use mysql-for-visualstudio-1.2.7 and mysql-connector-net-8.0.11 for connection.
Is there any possible way to fix it.
1st
Modify the MySql Server:
Open MySQL Installer - Community
Select Product MySQL Server
Click on Quick configure in last column
Click on next untill you will not point to Authentication method
On Authentication method tab- select Use Legacy Authentication method
Click on next and finish
Now you can login with normal password
2nd
If you are using .net framework 4.5.2
you can easy upgrade reference of MySQL.Data:
Visulastudio> Tools> Nuget Package Manager>Manage nuget package for solution
Go to Browse tab, Write Search textbox mysql and enter
first mysql.data package will come, install it
Now login, issue will resolved
This is a new authentication method used in MySQL version 8.0 as compared to mysql_native_password, which is the legacy method. In order to make this work, you will need to upgrade your MySQL Client library to version 8.0.
So, use the following link and get the version 8.0.11 or higher.
https://dev.mysql.com/downloads/connector/net/
I had the same issue. Fixed it by removing the reference to MySQL.Data then re-adding it.
Update the Pomelo.EntityFrameworkCore.MySql Nuget Package to 2.0.0.1 instead of 2.0.0
2.0.0.1 is more stable than 2.0.0 and 2.0.1
Just update your nuget package for MySql.Data
Our old .NET Framework 4.6.2 project began throwing this exception, when someone came back to using it after we updated MySQL server version few months ago.
So at first, as others recommend, I updated all packages via NuGet Package Manager (including MySql.Data to v8.0.24) - didn't seem to help at first. Then in project properties updated project target framework to .NET Framework 4.7.2 - still nothing.
Then I noticed the connection string had this providerName parameter:
<connectionStrings>
<add name="___" providerName="MySql.Data.MySqlClient" connectionString="server=___;user id=___;password=___;database=___;"/>
</connectionStrings>
so I tried removing the .MySqlClient part from it, leaving it
providerName="MySql.Data"
and for some reason it worked:) Maybe updating the MySql.Data package was part of the solution and the .MySqlClient is some obsolete property. No idea.
Do you hardly need the authentication method in MySQL to be 'caching_sha2_password'? If not, why don't you just switch it to 'Standard'?
You can check this in the "User and Privileges" settings and look for the Authentication Type.
I faced the same error while i was trying to connect my client machine to the Server. I had to connect to MySQL server hosted on the Server. I have got this to working. Followed the following steps:
Download the latest MySQL community version i.e 8.0.18.0 installed. Make sure that the same version of MySQL is installed in the server machine. Please note that either the same version of MySQL are installed in client machine and server machine or else client machine should have higher version of MySQL installed.
With the help of MySQL installer make sure that you installed 'Developer' version in your client machine, so as to have MySQL server, SQL.net, mySQL for visual studio e.t.c all will get installed in it.
We are using .Net framework 4.5.2 in latest MySQL community. So, make sure you using Visual studio 2019. Build UiConfigEDItor source code in Visual Studio 2019 so that it will have support for higher version .Net framework 4.5.
Now, copy all files (mysqlData.dll in particular) from SQL installed workspace(C:\Program Files (x86)\MySQL\Connector NET 8.0\Assemblies\v4.5.2) to Visual Studio 2019 workpace (C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE).
Log off you machine and now open UIConfigEditor source code in visual studio 2019.
Now in Solution Explore->References->Add References->Go to Assemblies tsb-> Extensions->Search for mysql.data.dll(make sure that its there)->check that option.
Please note that mysql.data.dll is of version 8.0.18.0 in this case.
Sometimes, it has a silly reason. In my case, I forgot to create my database in MySQL. Sometimes, one my forgot to run database daemon.
Not every scary error message is because of a scary situation.
I am starting to learn UWP platform. In first steps I want to do simple application (bookshop). Unfortunately, I got stuck on steps: how to use Entity Framework with SQL Server in UWP?
First I was using
Install-Package Microsoft.EntityFrameworkCore.SqlServer
but I got lots of conflicts (ex. System.Threading.Thread 4.3.0 error, or One or more packages are incompatible with UAP,Version=v10.0 (win10-x86).).
After that, I was trying add a classic dll to project (and install ef), but... classic library are incompatible with UWP...
Do you have any idea how to use EF with SQL Server in UWP ? I don't want to use sqlite...
Sorry you can only use the entity framework SQLite provider with UWP.
The latest version of Windows SDK (Falls Creators Update) will support direct SQL Server connection. Have a look at it here:
https://learn.microsoft.com/en-us/windows/uwp/data-access/sql-server-databases
To use SQLite in your UWP app, you need to target Windows 10 Fall Creators Update (10.0; Build 16299)
The NuGet packages are:
Microsoft.EntityFrameworkCore.Sqlite
Microsoft.EntityFrameworkCore
I successfully connected ms sql, entity framework to uwp.
They work together.
To connect, I used an additional project "csproj" with the standard .NetStandard 2.0 in the same solution. I also used "Microsoft.EntityFrameworkCore.SqlServer" in this project, not in the UWP project. It was just class library