Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
EF Core entity classes and Clean architecture

I am building a new ASP.NET Core 5 MVC app. I want to use clean architecture as outlined in Microsoft's web app architecture ebook.

I am also studying eShopOnWeb sample application available here :

https://github.com/dotnet-architecture/eShopOnWeb

What I understand from the ebook and sample app is - EF Core entity classes (say Customer, Product, Order) will go inside ApplicationCore project's Entities folder. The DbContext will be in Infrastructure project.

My confusion is: is it alright to add data annotation schema attributes such as [Table], [DatabaseGenerated], and [Key] on these entity classes inside ApplicationCore project? If not, where should I add these data annotations?

Any advice in this regards is highly appreciated.

Thank you.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In the example of eShopOnWeb they separate Entities and configuration models. So, that means to have clean architecture you don't need annotations directly in these Entities.

You can use FluentAPI, as they used as well in the Infrastructure/Data/Config directory.

So, if you have a separate project for DataContext that is the best location for describing your entities with FluentAPI in this case.

More information about FluentAPI: https://docs.microsoft.com/en-us/ef/ef6/modeling/code-first/fluent/types-and-properties

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!