ADO.NET Entity Framework or ADO.NET

前端 未结 3 1915
予麋鹿
予麋鹿 2021-02-15 23:42

I\'m starting a new project based on ASP.NET and Windows server.

The application is planned to be pretty big and serve large amount of clients p

3条回答
  •  孤城傲影
    2021-02-15 23:53

    Whether EF4 is really ready for production is a bit hard to say since it's not officially been released yet.... but all the preliminary experiences and reports about it seem to indicate it's quite good.

    However: you need to take into consideration what EF is trying to solve; it's a two-layer approach, one layer maps to your physical storage schema in your database (and supports multiple backends), and the second layer is your conceptual model you program against. And of course, there's the need for a mapping between those two layers.

    So EF4 is great if you have a large number of tables, if you have multiple backends to support, if you need to be able to map a physical schema to a different conceptual schema, and so forth. It's great for complex enterprise level applications.

    BUT that comes at a cost - those extra layers do have an impact on performance, complexity, maintainability. If you need those features, you'll be happy to pay that price, no question. But do you need that??

    Sure, you could go back to straight ADO.NET - but do you really want to fiddle around with DataTables, DataRows, and untyped Row["RowName"] constructs again?? REALLY???

    So my recommendation would be this:

    • if you need only SQL Server as your backend
    • if you have a fairly simple and straightforward mapping of one database table to one entity object in your model

    then: use Linq-to-SQL ! Why not?? It's still totally supported by Microsoft in .NET 4 - heck, they even did bugfixes and added a few bits and pieces - it's fast, it's efficient, it's lean and mean - so why not??

提交回复
热议问题