Search code examples
c#mysqlxamarin.ios

The type 'MySqlConnection' exists in both 'MySql.Data.CF' and in 'MySql.Data'


I am currently working on a Xamarin IOS project. In this project, I need MySql connection in order to complete several tasks.

When I write my code (the code below) the program throws an error.

        using var connection = new MySqlConnection(connectionString); // C# 8!
        connection.Open();

        using var command = connection.CreateCommand();
        command.CommandText = "SELECT * FROM Users WHERE Username = 'jack'"; 

        using var reader = command.ExecuteReader();

The program throws the following error:

The type 'MySqlConnection' exists in both 'MySql.Data.CF, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, Retargetable=Yes' and 'MySql.Data, Version=8.0.25.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' (CS0433) (firstios)

I do not have 'MySql.Data.CF' in my packets folder and it is not included in the .cs folder that I am working on.


Solution

  • I solved the issue by removing MySql.data and replacing it with MySqlConnector.