what is the secure way to store data in a database and applying validations too,in a code first approach if i don't want to use code first models.
repository,viewmodel,code first models
if it is viewmodel then what is the safest way to store and if it is code fisrt model then guide me is it a professional way to work?
Sachin SinghPosted Nov 26, 2022, 8:57 AM
Approaches varies depending upon the environment you are working in.
If you are a freelancer and full stack developer, then you should take code first approach. Where you can keep your models and Context class in a separate project and fluent validations in a separate project.
But, for enterprises, Database are designed by database developers and Application code is written by application developers, so most often we as an application developers get ready made database and multple stored procedures and functions, Data access layer is also not built over EF instead ado.net or Dapper, for this modifying application code just to use EF is not good, also complex sql queries are tough to achieve with linq/EF so we use SPs with CTEs, Pivots etc .