Join Richard Goforth for an in-depth discussion in this video When EF Core might not be a good choice, part of Accessing Existing Databases with Entity Framework Core.
- [Teacher] Let's talk about some of the reason that you wouldn't choose Entity Framework Core. Currently, Entity Framework Core is not in feature parity with Entity Framework 6. Check the current Entity Framework documentation to see if the feature that you're looking for has been added. With some of the features currently missing from Entity Framework Core include spatial data types like geography and geometry, complex query translation including group buy queries are done in memory rather than at the database. Lazy loading is available in Entity Framework 6.
I don't like using lazy loading because it hides data operations behind lines of code that don't look like they hit the database. I don't consider this a loss. Finally, model-first development is not available in Entity Framework Core. If you're used to using model-first development and you'd like to do that, Entity Framework Core is not for you. The next reason not to use Entity Framework Core is that your application needs the fastest possible database access. Some applications do a lot of heavy data operations with very high performance demands.
Usually business applications don't have that high of performance demand. Entity Framework Core is still good for millions and millions of rows. Usually the cost savings found in faster application development is more significant than just buying a more powerful server to run the application. The final reason not to use Entity Framework Core is that you're trying to cheat by not requiring your developers to understand what it means to work with a database. It's possible to write really bad queries in Entity Framework that are going to do things like bring 300,000 rows into memory and then throw it all away immediately.
There are also operations that can cause an application to use all the memory on a server or take several minutes to run. When a slightly different query could run in less than a second and require no additional resources. Developers still have to understand what they're doing and how the code they're writing affects the database. With these considerations in mind, you can decide whether Entity Framework Core is a good fit for your project.
- Setting up your project
- Connecting to a legacy database
- Scaffolding an initial model and context
- Improving the model
- Updating properties and indexes
- Adding concurrency tokens and timestamps
- Creating complex relationships
- Working with non-Microsoft databases such as SQLite and PostgreSQL