views:

75

answers:

2

I'm trying to familiarize myself a bit more with database programming, and I'm looking at different ways of creating a data access layer for applications. I've tried out a few ways but there is such a jungle of different database technologies that I don't know what to learn. For instance I've tried using datasets with tableadapters. Using that I am able to switch data provider rather easily (by programming against the interfaces such as IDbConnection). This is one thing I would want to achieve. But I also know everyone's talking about LINQ, and I'm trying to get to know that a bit better too. So I have tried using Linq to Sql classes as the data access layer as well, but apparently this is not provider independent (works only for SQL Server).

So then I read about the Entity Framework (which just as Linq to SQL apparently has gotten its share of bashing already...). It's supposed to be provider independent everybody says, but how? I tried out a tutorial to create an entity data model, but the only providers to choose from were SQL Server/Express. Just for learning purposes, I would like to know how to use the entity framework with MS Access/OleDb.

Also, I would appreciate some input on what is the preferred database technology for data access. Is it LINQ still after all the bashing, or should you just use datasets because they are provider independent? Any pointers for what to learn would be great, because it's just too much to learn it all if I'm not going to use it in the end...!

+2  A: 

the only providers to choose from were SQL Server/Express

The .NET Framework only includes EF providers for SQL Server and SQL Server Compact. If you need to access another DBMS, you need to install a third-party provider. For instance, there's a free provider for SQLite, with designer support. There are also a few (commercial) providers made by Devart, for various DBMS. As far as I know, there are no EF providers for OleDB or ODBC...

Thomas Levesque
Thanks. I'll look into that then, and try it out with some other database, perhaps MySQL.
Anders Svensson
The latest version of the official MySQL connector does support the Entity Framework, at least partially...
Thomas Levesque
Right, but see my comment to Christian below, for this to work the connector needs to be installed on the web host for me to use it there, right? If so, they don't do that...
Anders Svensson
It doesn't need to be installed on the host... You can deploy it with your app, and add the provider declaration to you web.config
Thomas Levesque
Really? Thanks, then I'll try that out!
Anders Svensson
A: 

I really like the metaphor from Scott Hanselman: "I'm not a plumber, but I do know what an S-Bend is."

Personally, I think you should have a working knowledge of all the variety of ways to access data.

ADO.Net, EF, Linq2Sql, txt files, xml etc etc etc.

Have a look at the Nerd Dinner and the Music Store samples. See the way they access data (how do they do Unit Tests, Mocking framework, IOC etc)

Regarding data providers, personally I would avoid Access. It is just as easy to get a Sql Express or Mysql installation running and looks better on your resume.

(For what its worth, this question discusses setting up mysql for EF.)

Christian Payne
Thanks, yes I do try to get a grip on as many technologies as possible, but with the pace of development it's hard to keep up, so I feel I need to be a bit selective to stay sane at least :-). I do use SQL Server Express, but since I wanted to try switching providers I needed something else as well. My web host allows your own ms access. I also have access to MySQL on the web host, but they don't have the connector/net for MySql, only one callled odbc 3.51. I assume they need the other one installed on the web host for the EF to work?
Anders Svensson