question

Brian-7574 avatar image
0 Votes"
Brian-7574 asked ZhiLv-MSFT commented

Layers for Razor and Entity Framework

I'm building a good size app with Razors pages and Entity Framework and am wondering about the architecture. Specifically the number of layers to use and how they should be set up. Main thing is I'd like to keep it simple and DRY so I'm thinking about implementing just two layers : a Presentation Layer and Data Layer. Any general recommendations for setting up a single Data Layer with EF and are there any tutorials you'd recommend? Or would you recommend at least a 3 layer approach? Thanks in advance

dotnet-aspnet-core-razor
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Brian-7574,

You can check the Common web application architectures, it can help you choose a right architecture. For the detail information about using All-in-one applications or Multiple layers application, you can search online (for example using Google search "asp net core razor page 3 layer architecture"), and there are many examples and documents about them.

1 Vote 1 ·

1 Answer

BruceBarker-8516 avatar image
0 Votes"
BruceBarker-8516 answered

Thats all you need if there is no business logic, only simple/no validation required, the pages are just simple mappings of the database objects and security is simple. I also assume no unit tests.

Are you only doing a 1 tier or an enterprise application?

I worry less about layers and more about separation of concerns. You should not be afraid to create as many projects as you need. Why should the UI know the database structure? Why should the UI know business logic? Why should the Business logic know where the data is stored.




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.