简体   繁体   中英

How do I set up a connection string for a MySQL database in a C# project without using dialog boxes?

NOTE: Apparently, the reason the MySQL connector installation doesn't show up automatically in the Dialog Boxes for adding a data source is because the Visual 2008 Express Edition doesn't allow "3rd party integration" within the Visual Studio IDE. So, this makes setting up the data source manually even more important because the integrated tools from the MySQL connector aren't present.


My goal is to set up a connection to a MySQL database using Entity Framework (an ADO.NET Entity Data Model). I'm getting frustrated by all the wizards and dialog boxes and I still can't find what I'm looking for.

Here's what I've done so far: I just installed the MySQL .NET Connector v6.1.3 on my machine (to my knowledge, it is correctly installed. It shows up in Add/Remove Programs in the Control Panel). In Visual Studio (Visual C# 2008 Express Edition SP1 with Entity Framework Version that ships with SP1), I click to add a reference to a project, click on "ADO.NET Entity Data Model" and that brings me to a screen that asks "What should the model contain?" I select "Generate from database" and then click Next.

This screen asks me which data connection I should use. I click "New Connection" and get a screen that looks like this:

Where's an option for the ADO.NET MySQL Connector that I just installed?

I know where to find the connection string for MySQL, but I can't figure out how to get it into my application so that Visual studio recognizes it, uses the ADO.NET connector, and allows me to select that connection to create an Entity Model. How can this be accomplished?

Use the app.config (or web.config) file to add a entry. Be sure the specify the provider= attribute correctly with the MySQL provider.

There is no support for third-party extensions in Visual C# 2008 Express Edition SP1.

This is mentioned in this blog post by Dan Fernandez.

More information about the difference between Express and Professional editions is available here in the Visual Studio 2008 Product Comparison article.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM