Answered by:
Splitting out data models

Question
-
User-357141231 posted
I see mixed views on doing this, but here's my use case.
It's not a big application, but the models are going to be used by some additional programs in the solution, mainly console applications. They could just reference the web project I guess, but this feels wrong?
In this case, should I split the data models out, or am I being pretentious.
Sunday, April 19, 2020 9:01 AM
Answers
-
User665608656 posted
Hi, infused
If your project is not very complicated, you do not need to separate your model, you only need to "add reference" in the console project to reference the namespace where the model you need.
The operation steps are as follows:
Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 20, 2020 8:30 AM
All replies
-
User1120430333 posted
They could just reference the web project I guess, but this feels wrong?
Yeah it is wrong, A console project should not be referencing a Web project for many reasons. The main one is a console program is a desktop program, and the ASP..NET program is a Web program. They run in two different environments.
In this case, should I split the data models out, or am I being pretentious.
The models are classes that can be created in a classlib project call it Models. The Models classlib project can be referenced by the console program project and the ASP.NET Web program project.
Sunday, April 19, 2020 12:22 PM -
User-357141231 posted
Thanks. The console app is actually a server application. It has to work on the dataset driven by the MVC program. I was clarifying this for myself as googling around, there seem to be many people agaisn't splitting the data models out.
I am using .net core3 mvc if it makes a difference.
Monday, April 20, 2020 3:54 AM -
User665608656 posted
Hi, infused
If your project is not very complicated, you do not need to separate your model, you only need to "add reference" in the console project to reference the namespace where the model you need.
The operation steps are as follows:
Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 20, 2020 8:30 AM