0

I'm currently using this article in an attempt to connect my ASP.NET Core project to my MySql database, and installed the NuGet package "MySqlConnector" as it said. The article then says to add this line to the "ConfigureServices" function in Startup.cs.

services.AddTransient<MySqlConnection>(_ => new MySqlConnection(Configuration["ConnectionStrings:Default"]));

However "MySqlConnection" is underlinde in red, and hovering over it shows the following error:

CS0246: The type or namespace "MySqlConnection" could not be found (are you missing a using directive or an assembly reference?)

Is there something I'm missing? Is there a typo in the article, and I should be installing the MySqlConnection package instead?

1 Answer 1

1

The class MySqlconnection is defined in the namespace MySqlConnector. You have to add the following using statement at the top of your Startup class:

using MySqlConnector;
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! That actually helps me understand more about how namespaces work too, since I'm still very much a beginner.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.