Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hai All, I am doing a project in MVC. I am trying to use the a single code to save the data in multiple tables. The real situation:

I have a student table and Teacher table. I want to use the same code to save the data in both the tables. Any idea to save the data in both the tables with the reusing of the code??

Thanks in Advance.
Posted
Comments
Sergey Alexandrovich Kryukov 3-Sep-14 1:20am    
Frankly, I have no idea how a service can be built as MVC. How a service can have "V" (view)?
Therefore, I cannot understand how this question may have any sense.
Any explanations?

Besides, which sense of MVC do you mean? If this is architecture, you should tell us your platform.

—SA

1 solution

You write the service where the context.SaveChanges would be present & get that service called from your controller.
This will also reduce coupling. Have the Add entity method and Context.SaveChanges() once
Hope this helps
Thanks
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900