0

i am new to the mvc and trying to connect my mysql database to the application using mvc..

my connection string is as-

<connectionString>
    <add name ="Controlsheetlogin" connectionString="Server=localhost; database=test;User Id=root;password=123"/>
</connectionString>

this is my connection string

and am getting error in MySql.Data.MySqlClient.MySqlCommand thanks in advance for any help.

and this is the error that i am getting

Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49
  • You could search for that error instead. Maybe there's a question on Stack Overflfow to help you with this specific case. – richerlariviere Nov 15 '17 at 15:08
  • Could you post the C# method where you are getting the error assuming it is relevant? – Dev Nov 15 '17 at 15:13
  • 2
    It would be helpful to include the exception in the text. – jHilscher Nov 15 '17 at 15:22
  • string constr = ConfigurationManager.ConnectionStrings["abc"].ConnectionString using (MySqlConnection con = new MySqlConnection(constr)) { using (MySqlCommand cmd = new MySqlCommand() ) am getting error in using – vaibhav Dhiman Nov 15 '17 at 15:28

1 Answers1

0

Your connection string does not look right. To Connect EF to MySQL you need to specify the provider as such:

[...] name="ConnectionString" providerName="MySql.Data.MySqlClient" [...]

Answers to this question may be helpful, as it details how to set up EF with MySQL.

Syl20
  • 117
  • 2
  • 18
  • From the screen shot of the errors you are getting you seem to be missing a number of references... Could you post your C# code so we can help you further? – Syl20 Nov 16 '17 at 11:15
  • I meant to edit your question with the relevant C# code (at least the full using block like you have in a comment but it's hard to read) and the using(s) declaration at the top as the errors message point to missing references... – Syl20 Nov 16 '17 at 13:01