views:

106

answers:

5

I see a lot of asp.net projects coupled with mssql2005 and mssql2008. Most of them don’t use MySQL for some reason.This is even true when an ORM like nhibernate is being used.

Is this a pattern only to me or are there quite a lot of asp.net projects with MySQL as the db?

If this is true, what might be the reason for not choosing MySQL?

+1  A: 

SQL Server is noticeably faster in a typical setup, has better graphical design tools, and is easier to administer. All Windows machines have a SQL Server driver preinstalled.

MySQL is free and also works on Unix servers. It requires a client library to be used in ASP.NET (the MySQL connector) which has to be installed on the machine running the IIS web server.

So, even though ASP.NET plays well with MySQL, it's both slower and more difficult. But if you can't afford SQL Server, or if licensing is an issue, MySQL is the way to go.

Andomar
Are you sure about the SQL server driver in "all Windows machines"? I've crawled through a lot of Windows configuration, and I've never seen it.
Cylon Cat
@Cylon Cat: visit the Administrative Tools -> ODBC Data Sources -> Drivers Tab. The SQL Server driver should be right there.
Andomar
OK, for ODBC, yes. But typical SQL server installs use a service, and .NET connects through the service. I've never seen ODBC actually used for SQL server.
Cylon Cat
@Cylon Cat: It's a *little* more complicated then that. .NET talks to the SQL Server driver, which talks to the SQL Server by sending TDS messages over a TCP connection (or in same rare cases, named pipes.) The SQL Server can be on a different physical machine. No server install is needed on the client. And an ASP.NET website is a client, from SQL Server's point of view.
Andomar
SqlClient, the SQL server driver for .NET is shipped with the .NET framework. So "all machines with .NET installed"
nos
The key component is the SQL Server service, which installs with the database, not with .NET. The connection will use named pipes if the database and application are on the same machine, but will use TCP otherwise. All .NET applications are clients, from SQL Server's point of view, except for .NET-based stored procedures. @nos, the .NET framework only contains SQL client support.
Cylon Cat
A: 

The last time I checked (and it's been a few years), the only way to access MySQL from .NET, using only out-of-the-box tools in Visual Studio, was using .NET's ODBC provider. I know there are better tools for MySQL and .NET, but the only one's I looked at, at the time, were not free. By contrast, .NET's SQL Server provider is fast, easy to set up, and very reliable.

Second, there are free versions of SQL Server (express editions), so cost isn't a factor unless the database exceeds 4GB in size. That's a limitation in the express editions.

Third, SQL server express edition comes with paid versions of Visual Studio, so it's already there for most developers. If you have an MSDN subscription, you get the developer edition of SQL server, which is the whole enterprise edition with restricted licensing. Again, there's not much incentive to go looking for another database when you've already got a good one.

Fourth, most versions of Visual Studio have excellent integration with SQL Server, so that you can edit tables as well as data, and design and test queries, in the Visual Studio environment. Good tools are always a win.

Cylon Cat
Things have moved foreward. e.g. you can install the Connector/.NET - official and free from mysql.com, and e.g. get visual studio integration for generating linq to mysql classes
nos
So it seems there's no major factor weighing either direction, then. However, for mission-critical applications, I would absolutely go with SQL Server, for performance, scalability, partitioning, reporting, recovery, mirroring, failover support, and analysis tools.
Cylon Cat
A: 

As long as you have a .NET connector for your database system, you can use . There is no special limitations that will prevent a database system from working with a specific language. The database system is a separate software system in its own. A connect creates a bridge between your software component/project/system to the database software.

This allows you to connect to (from .NET using the connectors): Oracle, PostGreSQL, MS-SQL, MySQL, SqlLite, ..... without much problem.

Database systems are designed to be implementation independent so that the data can be segregated from the users, and application and to be able to retain the main principles of database. (Atomic, Consistency, Isolation, and Durability)

monksy
+3  A: 

SQL Server is often a default for most .Net developers as that is what they are used to and the integration is good.

This doesn't mean that MySql doesn't feature. In fact there is a version of MySql Connector for ADO.Net. As for ORMs, Nhibernate comes with a Dialect for MySql and works well, I used this recently for a small project. In fact, if you let Nhibernate generate your schema you're free to choose between; MS SQL, MySql, Oracle or even, erm, Access.

Keith Bloom
+2  A: 

ASP.net connects to SQL Server Database with the Tabular Data Stream Protocol (TDS), which is different from the OleDB protocol it uses to connect to MySQL. This is a "closer to the metal" approach to connecting to the database, and as a result, is markedly faster.

You can see an ADO.NET diagram here which outlines the different paths.

This question is also covered here on Stack Overflow.

Kyle B.