Good day!

Studying the implementation of the MVC pattern using ASP.NET and reading a lot of tutorials on creating web applications using these tools, I noticed that almost everywhere they use MS SQL Server, because It integrates perfectly with Visual Studio.

But since before this database I created in MySQL Workbench, it is closer to me in terms of ease of operation. I tried to find ways to get data from the mysql database on the Internet, but found nothing concrete and useful. I found this:

  • metanit offers automatic database generation based on the model, which is not very convenient for me.

  • An article on the microsoft site suggests creating a database in Azure, then using mysql worckbench to connect to Azure, but in the application itself, the data is only added, it is not read from the database.

  • On the official MySql website , ADO technology was used (it suits me), but in step Figure 7.3 Creating a new MySQL connection , I do not have the MySql Database in the list, and when I try to use the connectionStrings I set in web.config as follows:

     <connectionStrings> <add name="DefaultConnection" connectionString="Server=localhost; user id=root; password=some-password; database=booksdb" providerName="MySql.Data.MySqlClient" /> </connectionStrings> 

    I still could not establish a connection with mysql using ADO, although I added the Entity Framework, MySql.Data.dll and MySql.Data.Entity to the solution. Incomprehensible crutches.

I think there are people here who have encountered this problem and, I hope, will be able to help me.

Thank you

  • and what metanit does not suit? - codename0082016
  • @ codename0082016 is not comfortable with the fact that there is a CodeFirst approach, i.e. Based on the models, the database is automatically generated, and I need the opposite, so that models (entities) are generated from an already existing database, or at least a manual connection to mysql is created, after which I would be able to get data from the database. - Andrei Khotko
  • one
    here it will not work with stackoverflow.com/questions/30415437/… right here about MySQL connectors dev.mysql.com/doc/connector-net/en/… - SergeyE
  • @Eikhner try, accomplish your goal when I finish - Andrei Khotko
  • metanit.com/sharp/articles/mvc/23.php there is something in the discussion below about connection and migration - SergeyE

1 answer 1

Shoveled a large number of articles, I found a solution. Thanks to Eikhner for sending the article .

It turns out that in addition to the installed MySQL.Data, MySQL.Data.Entity packages and the MySQL Net Connector software, it was necessary to pre-install the MySQL for Visual Studio software. After that, ADO.NET EDM, after some manipulations with the MySQL settings, generated models.

  • Andrei Khotko, and you could not describe in more detail some of the manipulations with the MySQL settings, because I do not create a data model. Everything is connected to the database via Server Explorer normally, but the stage of adding tables to the model does not reach, the wizard window just crashes and everything ... - user282093