.Net to MySQL

C++, C#, Java, PHP, ect...
Post Reply
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

.Net to MySQL

Post by hallsofvallhalla »

When looking for .Net hosts I am finding many have MySQL db options only. Is there a god library out there for connecting the two? I am not finding much. Anyone have any suggestions/advice on it?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: .Net to MySQL

Post by Jackolantern »

Yaay! I wrote a tutorial on this very topic! I hope it is still up to date :P
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: .Net to MySQL

Post by hallsofvallhalla »

haha i remember reading this and knew I had read one but could not for the life of me remember where I seen it at...Hehe now I know!

Thanks!
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: .Net to MySQL

Post by Jackolantern »

Awesome! Glad it can be useful! :)
The indelible lord of tl;dr
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: .Net to MySQL

Post by a_bertrand »

I would either use nhibernate or http://www.devart.com/linqconnect/ instead of ADO.NET ;)
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: .Net to MySQL

Post by Jackolantern »

Of course ORMs are likely a better option. NHibernate is a fairly complex option, however, and the tutorial was designed to just get the job done. NH is likely overkill for a smaller project.

As a side note, it is very irritating that EF doesn't support MySQL out of the box. I understand that MS sells SQL Server, but it supports Oracle and DB2. Why not the most popular RDBMS in the world?
The indelible lord of tl;dr
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: .Net to MySQL

Post by a_bertrand »

Beside the support for Oracle is nearly non-existant and you have to rely to some other options, it was not coded by MS but by Oracle which gave the thing to MS. Keep in mind you can't natively do LINQ to SQL to Oracle or any other DB beside MS SQL. So the only thing offered by .NET is ADO.NET to Oracle or DB2... which basically you can do to MySQL as well with a single simple download (and for free). I don't see much difference. Even for oracle you are forced to download a better ADO.NET from Oracle website... basically the same effect.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: .Net to MySQL

Post by Jackolantern »

Actually, technically you can't really natively connect Entity Framework to any database. Every RDBMS requires a mapping layer. EF only connects to an interface. MS SQL's mapping layer is included out-of-the-box with EF, but there are mapping layers available for Oracle and DB2.

Now that I think about it, it is likely that Oracle and DB2 mapping layers exist because these are commercial products where a company has a financial interest in creating the (fairly complex) mapping layers for their respective RDBMS. But I would still think this would have been undertaken by the open source community that supports MySQL. MS does publicly allow for the creation of new mapping layers.

EDIT: Actually, this exact thing is possible, at least on some level (I have no idea how complete or useful it is).
The indelible lord of tl;dr
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: .Net to MySQL

Post by a_bertrand »

I gave the link to LinqConnect which offer actually a better option than what MS offer even for MS SQL. It's free to use up to 10 tables, then you need to pay a license.

And I fully know you can develop your own, I even started to make my own before finding LinqConnect which I then purchased here at work.

Why MS should offer it for all? No need. Even Java doesn't offer ANY mapping to any DB. They offer the base DB factories, and then each provider need to code their own. For me it is the right way to do it. It is not like MS is developing NVIDA and AMD graphic drivers, right? Well same for DB. If you choose a DB, then you will have to go to the DB provider to provide you with a DB driver.

Now you could arguee that MS do offer it for MS SQL, well, sure, they develop the DB too, why not offer it directly? Also, SQL Express is free to use up to 10GB of DB, 1GB of ram and a single socket CPU. For me, that should fit any hobby / amateur project. If your project requires more, then you can purchase a MS SQL license.

BTW If you never worked with MS SQL or SQL Express, I would say you should try it. It's actually much better than MySQL ;)
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: .Net to MySQL

Post by Jackolantern »

I never denied that it was. I enjoy MS SQL. But MySQL is the most popular RDBMS in the world, so of course many people will be using it.

I had never heard of LINQConnect, but will check it out. I was worried the prices would be very high (as I am sure you know, a ton of third-party .NET tools and libraries are designed for enterprise development and cost thousands of dollars), but they weren't bad at all single developers.

If I do start working with .NET in a serious way again, I will check it out. But for now I am mostly working with node and MongoDB.
The indelible lord of tl;dr
Post Reply

Return to “Coding”