I have seen that in some systems, relationships are mapped in Entity Framework without being mapped in the SQL tables. What is the point of using Entity Framework to map relationships over mapping them in SQL?
Asked
Active
Viewed 176 times
0
2 Answers
1
Real answer? No good reason unless you need them in the app, and you don't control the database, and it doesn't have them.
Generally, instead of that, it's a developer who's assuming that "the app does that" in terms of relationships, and also assumes that no other app or process will ever touch that data.
Here's a blog post on the latter: https://blog.greglow.com/2016/05/31/should-my-database-have-foreign-key-constraints/

Greg Low
- 1,526
- 1
- 4
- 4
1
First, If you use Entity framework in large system, it will reduce much code.
Second, we don't need to concern about how to connect to database.
Third,Entity framework can be used as infrastructure for data services and OData services.

Jack J Jun
- 5,633
- 1
- 9
- 27
-
1Large systems are usually the last place that you want EF. Large systems are where you need precise control over the queries being executed. I spend my life fixing performance problems at large sites where people have used EF. For example, it has many poorly chosen internal defaults. OK for toy systems, not OK for large systems. – Greg Low Jan 09 '20 at 03:50
-
So the best practice is mapping in DB itself? – Chanuka Naveen Koswatta Jan 09 '20 at 06:57
-
I suggest that it is best for you to use sql table itself if you want to make a a real-time program. If you want to transfer data from your database to a cloud based data service, you can use Entityframework. – Jack J Jun Jan 09 '20 at 08:22