When using Blazor WebAssembly, be default, three projects are created - Client, Server and Shared. Which project is the best choice for code which defines EF Core data model?
It seems like I'm picking the lesser of three evils, which seems to be the Fluent API. Are there any other aspects that I didn't consider?
You put DTOs (Data Tranfer Objects) in the Shared project. That is one of the key benefits of Blazor.
You can use your Model Entities as DTOs but I would only consider that for (very) small projects. And then EF (DbContext and Fluent API) is still only needed on the Server. Don't add it to the Shared project.
For larger projects, use separate DTOs and do the mapping in the Server APIs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With