EF6 Model Separation
I am trying to have a common model referenced by multiple programs, and not sure how to design it correctly for re-use. Not all programs are going to need all parts of the model, but id prefer not to have different versions of it from a source control point of view.
I have created a (simplified) model in EF6 that incorporates the following:
Locations
Materials
Formulas
My business logic can add materials to formulas or locations:
AddMaterialToLocation(Material material)
AddMaterialToFormula(Material material)
Referencing program one needs all of the above. It has a formulations system, and a warehouse, so it wants to use both of the above functions.
Referencing program two however only has a warehouse, it doesn't need formulas. The referenced model however still does. (Program two is on a different database/PC altogether)
Of course any changes in the material or warehousing should be applied as an update to the common model, updating both programs.
I have looked at doing it the following ways: -
- To have the model all joined together as one, but have program two not bother to call the parts it doesn't need.
- To split the model in two parts. Have one half have two tables/entity classes (Locations/Materials) and the other half to have (Formulas/Materials). This allows program two to only create the part of the model it needs.
- Split the model in three parts, one per table/class. Have each program build up the parts individually and pass/convert between them using only basic types?
AddMaterialToLocation(int MaterialCode, string MaterialName)
The referencing applications will both build up their own view models in the presenter anyway, so attaching the smaller pieces together after is fine.
The above solutions seem to come up with the following downsides:-
Option 1 - would end up creating lots of unused entities for program two.
Option 2 - would have two Material entites the same (which would also be the same db table)
Option 3 - would have a lot of edmx's. Nothing would be linked - id loose navigation properties etc.
Is there a better way?
c# design-patterns database-design entity-framework-6
add a comment |
I am trying to have a common model referenced by multiple programs, and not sure how to design it correctly for re-use. Not all programs are going to need all parts of the model, but id prefer not to have different versions of it from a source control point of view.
I have created a (simplified) model in EF6 that incorporates the following:
Locations
Materials
Formulas
My business logic can add materials to formulas or locations:
AddMaterialToLocation(Material material)
AddMaterialToFormula(Material material)
Referencing program one needs all of the above. It has a formulations system, and a warehouse, so it wants to use both of the above functions.
Referencing program two however only has a warehouse, it doesn't need formulas. The referenced model however still does. (Program two is on a different database/PC altogether)
Of course any changes in the material or warehousing should be applied as an update to the common model, updating both programs.
I have looked at doing it the following ways: -
- To have the model all joined together as one, but have program two not bother to call the parts it doesn't need.
- To split the model in two parts. Have one half have two tables/entity classes (Locations/Materials) and the other half to have (Formulas/Materials). This allows program two to only create the part of the model it needs.
- Split the model in three parts, one per table/class. Have each program build up the parts individually and pass/convert between them using only basic types?
AddMaterialToLocation(int MaterialCode, string MaterialName)
The referencing applications will both build up their own view models in the presenter anyway, so attaching the smaller pieces together after is fine.
The above solutions seem to come up with the following downsides:-
Option 1 - would end up creating lots of unused entities for program two.
Option 2 - would have two Material entites the same (which would also be the same db table)
Option 3 - would have a lot of edmx's. Nothing would be linked - id loose navigation properties etc.
Is there a better way?
c# design-patterns database-design entity-framework-6
add a comment |
I am trying to have a common model referenced by multiple programs, and not sure how to design it correctly for re-use. Not all programs are going to need all parts of the model, but id prefer not to have different versions of it from a source control point of view.
I have created a (simplified) model in EF6 that incorporates the following:
Locations
Materials
Formulas
My business logic can add materials to formulas or locations:
AddMaterialToLocation(Material material)
AddMaterialToFormula(Material material)
Referencing program one needs all of the above. It has a formulations system, and a warehouse, so it wants to use both of the above functions.
Referencing program two however only has a warehouse, it doesn't need formulas. The referenced model however still does. (Program two is on a different database/PC altogether)
Of course any changes in the material or warehousing should be applied as an update to the common model, updating both programs.
I have looked at doing it the following ways: -
- To have the model all joined together as one, but have program two not bother to call the parts it doesn't need.
- To split the model in two parts. Have one half have two tables/entity classes (Locations/Materials) and the other half to have (Formulas/Materials). This allows program two to only create the part of the model it needs.
- Split the model in three parts, one per table/class. Have each program build up the parts individually and pass/convert between them using only basic types?
AddMaterialToLocation(int MaterialCode, string MaterialName)
The referencing applications will both build up their own view models in the presenter anyway, so attaching the smaller pieces together after is fine.
The above solutions seem to come up with the following downsides:-
Option 1 - would end up creating lots of unused entities for program two.
Option 2 - would have two Material entites the same (which would also be the same db table)
Option 3 - would have a lot of edmx's. Nothing would be linked - id loose navigation properties etc.
Is there a better way?
c# design-patterns database-design entity-framework-6
I am trying to have a common model referenced by multiple programs, and not sure how to design it correctly for re-use. Not all programs are going to need all parts of the model, but id prefer not to have different versions of it from a source control point of view.
I have created a (simplified) model in EF6 that incorporates the following:
Locations
Materials
Formulas
My business logic can add materials to formulas or locations:
AddMaterialToLocation(Material material)
AddMaterialToFormula(Material material)
Referencing program one needs all of the above. It has a formulations system, and a warehouse, so it wants to use both of the above functions.
Referencing program two however only has a warehouse, it doesn't need formulas. The referenced model however still does. (Program two is on a different database/PC altogether)
Of course any changes in the material or warehousing should be applied as an update to the common model, updating both programs.
I have looked at doing it the following ways: -
- To have the model all joined together as one, but have program two not bother to call the parts it doesn't need.
- To split the model in two parts. Have one half have two tables/entity classes (Locations/Materials) and the other half to have (Formulas/Materials). This allows program two to only create the part of the model it needs.
- Split the model in three parts, one per table/class. Have each program build up the parts individually and pass/convert between them using only basic types?
AddMaterialToLocation(int MaterialCode, string MaterialName)
The referencing applications will both build up their own view models in the presenter anyway, so attaching the smaller pieces together after is fine.
The above solutions seem to come up with the following downsides:-
Option 1 - would end up creating lots of unused entities for program two.
Option 2 - would have two Material entites the same (which would also be the same db table)
Option 3 - would have a lot of edmx's. Nothing would be linked - id loose navigation properties etc.
Is there a better way?
c# design-patterns database-design entity-framework-6
c# design-patterns database-design entity-framework-6
edited Nov 13 '18 at 13:40
iXDev
asked Nov 13 '18 at 11:54
iXDeviXDev
205
205
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Each problem domain has its own solution space and have specific business model for it.
when you try to create model for program one,it has its own model that existed in its definition not any more(option 1 downside).
why you want to depending two program to each other when they are completely separated in machine and data base?
maybe in later you want to apply any changes to program one that it is not necessary in program two and it brings complexity to you!!
but if your common model have same data (shared data) for two program you can use some solution like Microservice for common model.(i don't know your programs detail)
Hi, thanks for your input. I will look into those.
– iXDev
Nov 14 '18 at 9:15
They are independent unrelated programs but in reality they will be built up of a series of identical blocks/modules depending on the program. I could potentially write program one (the bigger one), then paste the model/BLL code across, delete the bits not used, and build program two's UI project referencing the cut down model. But when I want to add a new feature/function for the warehousing, ill have to apply it to both projects. I was hoping if I could design it right, I could have separate projects/modules which get pulled into both projects when a new version is released.
– iXDev
Nov 14 '18 at 9:21
if common model for two projects always have same changes but data is different,you can put your functionality and services of your common model in a microservice then for different applications use different tenants. good luck.
– MRMF
Nov 14 '18 at 10:23
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280507%2fef6-model-separation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Each problem domain has its own solution space and have specific business model for it.
when you try to create model for program one,it has its own model that existed in its definition not any more(option 1 downside).
why you want to depending two program to each other when they are completely separated in machine and data base?
maybe in later you want to apply any changes to program one that it is not necessary in program two and it brings complexity to you!!
but if your common model have same data (shared data) for two program you can use some solution like Microservice for common model.(i don't know your programs detail)
Hi, thanks for your input. I will look into those.
– iXDev
Nov 14 '18 at 9:15
They are independent unrelated programs but in reality they will be built up of a series of identical blocks/modules depending on the program. I could potentially write program one (the bigger one), then paste the model/BLL code across, delete the bits not used, and build program two's UI project referencing the cut down model. But when I want to add a new feature/function for the warehousing, ill have to apply it to both projects. I was hoping if I could design it right, I could have separate projects/modules which get pulled into both projects when a new version is released.
– iXDev
Nov 14 '18 at 9:21
if common model for two projects always have same changes but data is different,you can put your functionality and services of your common model in a microservice then for different applications use different tenants. good luck.
– MRMF
Nov 14 '18 at 10:23
add a comment |
Each problem domain has its own solution space and have specific business model for it.
when you try to create model for program one,it has its own model that existed in its definition not any more(option 1 downside).
why you want to depending two program to each other when they are completely separated in machine and data base?
maybe in later you want to apply any changes to program one that it is not necessary in program two and it brings complexity to you!!
but if your common model have same data (shared data) for two program you can use some solution like Microservice for common model.(i don't know your programs detail)
Hi, thanks for your input. I will look into those.
– iXDev
Nov 14 '18 at 9:15
They are independent unrelated programs but in reality they will be built up of a series of identical blocks/modules depending on the program. I could potentially write program one (the bigger one), then paste the model/BLL code across, delete the bits not used, and build program two's UI project referencing the cut down model. But when I want to add a new feature/function for the warehousing, ill have to apply it to both projects. I was hoping if I could design it right, I could have separate projects/modules which get pulled into both projects when a new version is released.
– iXDev
Nov 14 '18 at 9:21
if common model for two projects always have same changes but data is different,you can put your functionality and services of your common model in a microservice then for different applications use different tenants. good luck.
– MRMF
Nov 14 '18 at 10:23
add a comment |
Each problem domain has its own solution space and have specific business model for it.
when you try to create model for program one,it has its own model that existed in its definition not any more(option 1 downside).
why you want to depending two program to each other when they are completely separated in machine and data base?
maybe in later you want to apply any changes to program one that it is not necessary in program two and it brings complexity to you!!
but if your common model have same data (shared data) for two program you can use some solution like Microservice for common model.(i don't know your programs detail)
Each problem domain has its own solution space and have specific business model for it.
when you try to create model for program one,it has its own model that existed in its definition not any more(option 1 downside).
why you want to depending two program to each other when they are completely separated in machine and data base?
maybe in later you want to apply any changes to program one that it is not necessary in program two and it brings complexity to you!!
but if your common model have same data (shared data) for two program you can use some solution like Microservice for common model.(i don't know your programs detail)
answered Nov 14 '18 at 7:15
MRMFMRMF
357
357
Hi, thanks for your input. I will look into those.
– iXDev
Nov 14 '18 at 9:15
They are independent unrelated programs but in reality they will be built up of a series of identical blocks/modules depending on the program. I could potentially write program one (the bigger one), then paste the model/BLL code across, delete the bits not used, and build program two's UI project referencing the cut down model. But when I want to add a new feature/function for the warehousing, ill have to apply it to both projects. I was hoping if I could design it right, I could have separate projects/modules which get pulled into both projects when a new version is released.
– iXDev
Nov 14 '18 at 9:21
if common model for two projects always have same changes but data is different,you can put your functionality and services of your common model in a microservice then for different applications use different tenants. good luck.
– MRMF
Nov 14 '18 at 10:23
add a comment |
Hi, thanks for your input. I will look into those.
– iXDev
Nov 14 '18 at 9:15
They are independent unrelated programs but in reality they will be built up of a series of identical blocks/modules depending on the program. I could potentially write program one (the bigger one), then paste the model/BLL code across, delete the bits not used, and build program two's UI project referencing the cut down model. But when I want to add a new feature/function for the warehousing, ill have to apply it to both projects. I was hoping if I could design it right, I could have separate projects/modules which get pulled into both projects when a new version is released.
– iXDev
Nov 14 '18 at 9:21
if common model for two projects always have same changes but data is different,you can put your functionality and services of your common model in a microservice then for different applications use different tenants. good luck.
– MRMF
Nov 14 '18 at 10:23
Hi, thanks for your input. I will look into those.
– iXDev
Nov 14 '18 at 9:15
Hi, thanks for your input. I will look into those.
– iXDev
Nov 14 '18 at 9:15
They are independent unrelated programs but in reality they will be built up of a series of identical blocks/modules depending on the program. I could potentially write program one (the bigger one), then paste the model/BLL code across, delete the bits not used, and build program two's UI project referencing the cut down model. But when I want to add a new feature/function for the warehousing, ill have to apply it to both projects. I was hoping if I could design it right, I could have separate projects/modules which get pulled into both projects when a new version is released.
– iXDev
Nov 14 '18 at 9:21
They are independent unrelated programs but in reality they will be built up of a series of identical blocks/modules depending on the program. I could potentially write program one (the bigger one), then paste the model/BLL code across, delete the bits not used, and build program two's UI project referencing the cut down model. But when I want to add a new feature/function for the warehousing, ill have to apply it to both projects. I was hoping if I could design it right, I could have separate projects/modules which get pulled into both projects when a new version is released.
– iXDev
Nov 14 '18 at 9:21
if common model for two projects always have same changes but data is different,you can put your functionality and services of your common model in a microservice then for different applications use different tenants. good luck.
– MRMF
Nov 14 '18 at 10:23
if common model for two projects always have same changes but data is different,you can put your functionality and services of your common model in a microservice then for different applications use different tenants. good luck.
– MRMF
Nov 14 '18 at 10:23
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280507%2fef6-model-separation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown