In Webforms you could use an ObjectDataSource, use methods defined in your Business Logic Layer that would get data from your Data Layer, usually a data set or EF. Then all the code accessing database would be all in one place and retrieved logically based on methods.
In .Net Core Razor, how do you organize this?