Visual Studio ADO .NET can't connect to mysql database - c#

I work on Windows Forms project in C# and I need to connect to mysql database (localhost:3306).
I use Entity framework 6.4.0 and .NET Connector 8.0.18.
When I go to Project -> Add New Item -> Data -> ADO .NET Entity Model and go to Code First from database -> New Connection , my Choose Data Source Dialog haven't option for MYSQL DATABASE
I have Mysql Workbench 8.0 and I connected to database.
When I click on other option I have dialog:
Can't find database to select.
Where is the problem?

For that case, it normally happens when you install visual studio after installation of MySQL. Try re-installing MYSQL then it will have to work.
Note: Ensure backing up all your databases first
Happy programming.

Related

Trying to use Entity Framework with Oracle DB

Hi I am trying to use Entity-Framework in asp.net MVC , for that I have installed Oracle.Managed.DataAccess version 19.6.0 and Oracle.Managed.DataAccess.EntityFramework version 19.6.0
and oracle version 11.2.0 I am able to connect Oracle DB in server explorer but while adding new item in solution not getting any option to connect Oracle DB what is the issue I am not able to identify ,Any idea would be appreciated.
Image
Those are just the Nuget packages to allow your project to connect to Oracle.
I believe you need to add Oracle Developer Tools for Visual Studio to have the options available in the Visual Studio dialogs.
https://www.oracle.com/database/technologies/developer-tools/visual-studio/
You need to install a Oracle Client and TNSNAMES.ORA
The installation has a component list, if you insall that components (like Oracle developer Tools for visualStudio) it you can add your EF. and then when you finish you only need to add your TNSNAMES in order to create the Entities in VS.

How to connect XAMPP MySQL to ADO.NET Entity Framework using Visual Studio?

I am creating a project with ASP.NET and which would be connected on our University website and their currently using XAMPP MySQL on their system so I need to adjust on their database technology at the same time I want to implement Entity Framework of C# for faster development. Thanks you.
Ive already tried adding references on the project like MySQL.Data and installing MySQL Connector for Visual Studio but turns out it is for the MySQL not the XAMPP MySQL.
You can connect to your MySQL db in Visual Studio by going to the Server Explorer and click on the Connect to Database. Then select Microsoft ODBC Data Source and click continue. Make sure you enter your connection string.
This might be of help to you : https://www.youtube.com/watch?v=EhqknuizUKk

Connecting to MySQL in VS2017 in ASP.NET MVC 5 project

I'm new to ASP.NET and MVC, trying to move from WinForms. I'm using Visual Studio 2017 Pro, and I am trying to follow some tutorials for connecting to an existing MySQL database. I plan to use the Database First method as the database already exists. I have the following config :-
Windows 10 Pro 64 bit on my PC
VS 2017 Pro
MySQL for Visual Studio 2.0.5
MySQL Connector 6.10.4
EntityFramework v6.2.0
Mysql.Data 6.10.4
Mysql.Data.Entity 6.10.4
Mysql.Web 6.10.4
I can make a database connection using the Server Explorer, but when I'm using the EDM wizard to create the model from the database, the connection isn't showing in the drop-down box, and if I try to create a new one, the MySQL driver doesn't show as an available option, only SQL Server.
I've tried various combinations of MySQL for VS, MySQL Connector, EF and MySQl components (older versions) but I can't seem to find a winning combination.
Has anyone managed to achieve this ? I'm pulling out what's left of my hair. Thanks.
enter image description here
OK I finally found an answer, I now have EF 6.1.3 and MySQL Connector 6.9.9 installed.
I needed to change the part of the Web.Config file as described by James Wilkins in this post.
Thanks to Panagiotis for your help.

Connecting ado.net Entity data model to postgresql database

I'm new to C#, ado.net and visual studio 2012, just to make that clear from the beginning.
I'm trying to connect an ADO.NET Entity Data Model to a postgresql database.
I tell VS to 'generate mdoel from database' and click to make a new connection. Postgresql is not listed as an alternative data source (I can only see different microsoft mysql sources).
I did download the npsql .dlls and put them in the projects\ folder. I then added them by PROJECT->Add Reference->browse, check them and press ok.
Postgresql does still not appear as an alternative when I try to make a new connection.
In advance, thanks!

Does Visual Studio Server Explorer support custom database providers?

I had used Server Explorer and related tools for graphical database development with Microsoft SQL Server in some of my learning projects - and it was a great experience. However, in my work I deal with Oracle DB and SQLite and my hobby projects use MySQL (because they are hosted on Linux).
Is there a way to leverage the database-related tools in Visual Studio with other database providers?
Here is instructions on how to connect to your MySQL database from Visual Studio:
To make the connection in server
explorer you need to do the following:
first of all you need to install the MyODBC connector 3.51 (or latest) on
the development machine (NB. you can
find this at
http://www.mysql.com/products/connector/odbc/
)
Create a datasource in Control Panel/Administrative Tools with a
connection to your database. This data
source is going to be used purely for
Server Manager and you dont need to
worry about creating the same data
source on your clients PC when you
have made your VS.NET application
(Unless you want to) - I dont want to
cover this in this answer, too long.
For the purpose of this explanation I
will pretend that you created a MyODBC
data source called 'AADSN' to database
'noddy' on mysqlserver 'SERVER01' and
have a root password of 'fred'. The
server can be either the Computer Name
(found in Control
Panel/System/Computer Name), or
alternatively it can be the IP
Address. NB. Make sure that you test
this connection before continuing with
this explanation.
open your VS.NET project
go to server explorer
right-click on 'Data Connections'
select 'Add Connection'
In DataLink Properties, go to the provider tab and select "Microsoft OLE
DB Provider For ODBC drivers"
Click Next
If you previously created an ODBC data source then you could just select
that. The disadvantage of this is that
when you install your project
application on the client machine, the
same data source needs to be there. I
prefer to use a connection string.
This should look something like:
DSN=AADSN;DESC=MySQL ODBC 3.51 Driver
DSN;DATABASE=noddy;SERVER=SERVER01;UID=root;PASSWORD=fred;PORT=3306;SOCKET=;OPTION=11;STMT=;
If you omit the password from the
connection string then you must make
sure that the datasource you created
(AADSN) contains a password. I am not
going to describe what these mean, you
can look in the documentation for
myodbc for that, just ensure that you
get a "Connection Succeeded" message
when you test the datasource.
I found this during my research on Sqlite. I haven't had the chance to use it though. Let us know if this works for you.
http://sqlite.phxsoftware.com/
System.Data.SQLite System.Data.SQLite is the original
SQLite database engine and a complete
ADO.NET 2.0 provider all rolled into a
single mixed mode assembly.
...
Visual Studio 2005/2008 Design-Time
Support
You can add a SQLite connection to the
Server Explorer, create queries with
the query designer, drag-and-drop
tables onto a Typed DataSet and more!
SQLite's designer works on full
editions of Visual Studio 2005/2008,
including VS2005 Express Editions.
NEW You can create/edit views, tables, indexes, foreign keys,
constraints and triggers interactively
within the Visual Studio Server
Explorer!
The Server Explorer should support any database system that provides an ODBC driver. In the case of Oracle there is a built in driver with Visual Studio.
In the Add Connection Dialog click the change button on the data source you should then get a list of the providers you have drivers for.
Oracle has a set of tools that integrates with Visual Studio. It's packaged with their data access libraries.
http://www.oracle.com/technology/software/tech/windows/odpnet/index.html

Categories