Entity Framework VS pure Ado.Net

前端 未结 4 822
难免孤独
难免孤独 2020-12-04 18:16

EF is so widely used staff but I don\'t realize how I should use it. I met a lot of issues with EF on different projects with different approaches. So some questions brought

4条回答
  •  误落风尘
    2020-12-04 18:36

    Entity Framework is not efficient in any case as in most tools or toolboxes designed to achieve 'faster' results.

    1. Access to database should be viewed as a separate tier using store procedures as the interface. There is no reason for any application to have more than absolutely require CRUD operations. Less is more principle. Stored procedures are easy to write, secure, maintain and is de facto fastest way. It's easy to write tools to generate desired codes for POCO and DbContext through stored procedures.

    2. Application well designed should have a limited numbers of connection strings to database and none of which should be the all mighty God. Using schema to support connection rights.

    3. Lazy loading are false statements added to solve a problem that should never exist and introduced with ORM and its plug and play features. Data should only be read when needed. Developers should be responsible to implement this logic base on application context.

    4. If your application logic has a problem to maintain states, no tool will help. It will in fact, make it worse by cover up the real problem until it's too late.

    5. Database first is the only solution for a well designed application. Civilization realized long time ago the important of solid aqueduct and sewer system. High level code can and will be replaced anytime but data stays. Rewrite an entire application is matter of days if database is well designed.

    6. Applications are just glorified database access. Still true in most cases.

    This is my conclusion after many years in business applications debugging through codes produced by many different tools or toolboxes. The faster results advertised are not even close to cover the amount of time/energy wasted later trying to clean up the mess. Performance issues are rarely if not ever caused by high demand but the sum of all 'features' added through unusable tools.

提交回复
热议问题