I assume that you are asking about design and execution pattern. I would generally say no:
While you can split your database into several data contexts, then it would be desirable if and only if there was zero overlap between the two contexts.
Overlap is bad
eg. you have WebsiteContext and AdminContext . WebsiteContext designed to display Product and fulfill Order s. A WebsiteUser attaches to Order . AdminContext intended for your Staff members to process refunds for canceled Orders , which also link to WebsiteUser . AdminContext also needs to reset passwords and update other data for WebsiteUser .
You think about it because you do not want the website to process or even know about Returns
WebsiteContext Product -- Order -- WebsiteUser AdminContext Staff -- Returns -- Order -- WebsiteUser
In the above example, we see that we duplicate many objects in different data contexts. This smells bad, and it actually indicates that artificially dividing the database into different data contexts is the wrong solution. Do you have> 2 databases in the end or only one? Duplication violates the DRY (Dont Repeat Yourself) principle, because WebsiteContext.WebsiteUser is not the same as AdminContext.WebsiteUser, and in all likelihood the code will be messy when something has to take care which one they refer to them.
The Linq data context is just an OR mapper, and should be considered a bizarre black box that makes it easy to write a data access code. Some linq demos show that you no longer need other layers, but a program of any complexity still uses a multi-level design.
You are probably better off treating Linq objects as objects to easily transfer data and create a domain layer that hides them as an implementation detail. Read the DDD-Domain Driven Design.
By itself, using Linq objects from the user interface most closely resembles the Transaction Script template. In this case, you still get a logical level that will take care of the details.
Although you do not want the responsibility for the context to be so broad, the data context is simply a representation of the database. This is not a security mechanism, and it cannot stop you from corrupting data.
Robert Paulson
source share