问题
If you were programming a small database application in .NET 2008 right now would use plain ADO.Net or ADO.Net Entity Framework or some of both both?
I'm using Visual Studio 2008 to learn .Net. I already do quite a bit of programming in MS Access VBA but I've decided it's time to move past the desktop and past the 90's. My question is partially about what I should learn but also very much about what I should actually use in the real world.
回答1:
Technically Entity Framework is the evolution of ADO.Net. Do yourself a favor and dump data sets in favor of a more robust ORM. At this point nobody should be passing around DataSets anymore.
It is worth noting that Entity Framework is not your only option when it comes to ORMs. There is NHibernate, SubSonic, LINQ to SQL, etc... All of which will work just fine in 2008. EF 1 is not fully baked in my opinion.
回答2:
I would not use the version of Entity Framework that comes with VS 2008. Entity Framework with VS2010 is fine.
I likely wouldn't use ADO.NET either as I always seem to end up writing my own custom ORM then.
For .NET 3.5 / VS 2008, I would recommend NHibernate. Linq To Sql is maybe an option if you want to get started quickly and can throw away the project after you are done (since any project with a long life will probably have to be rewritten to use EF or NHibernate anyway).
So, try NHibernate first, if the learning curve is too intimidating, drop back to LinqToSql or EF. Once you've learned one ORM, learning the second ORM is much easier.
Also, you can read a lot more on choosing an ORM for .NET here:
NHibernate, Entity Framework, active records or linq2sql
回答3:
If your database is small enough and you don't have a lot of queries, do ADO.NET, but if you are taking anything of scale, do the Entity Framework as it will be worth the overhead. The data generation and native query keywords will drastically reduce errors.
回答4:
If you learning, use EF. Whats the point of going backwards. It makes dev a LOT easier. The ADO/Dataset way of doing things is dead. Also if you moving to the web then it is nice to use EF with WCF data services. Its a neat trick to know.
Secondly, why use 2008. IF you learning, get the latest tools. The express editions are really great.
来源:https://stackoverflow.com/questions/5268546/ado-net-or-entity-framework-in-visual-studio-2008