Mohammad Dayyan wrote: <layer>Repository Pattern
Repository Pattern is just applying a new name to an old idiom - a database layer. And yes you should have a database layer.
Mohammad Dayyan wrote:with Singleton to have the same DbContext in each entity's instance?
Is is ok to use a Singleton? I doubt it.
(from your other post...)
otherwise, for each entity we have to write Update, Delete, Insert, Reposit
Not sure what you think you are doing but you are going to need to do that regardless.
Mohammad Dayyan wrote:<layer>Static class is an instance for all, and it has the same position in RAM of system.
but Singleton has a static field and we can have different instances of our class, but we prevent coupling
As stated that is basically all wrong.
First classes, not data, all exist as a single instance (again the class and not the class instance) in memory excluding AppDomains.
Second in modern OSes the OS moves applications, everything including data, code and OS management stuff associated with application around all the time including moving it to the hard drive. So it can never be said to be in one place in the RAM.
Third class instances (not the class this time) are managed by the C# heap and it can move them around in memory. So it won't even be in the same place in virtual memory.
Fourth, although a Singleton has a rigid definition the conceptual idea of a 'single' instance can take many forms, including implementing access via a static class.
Fifth, none of that has anything to do with coupling.
I suspect that you should at least first attempt to write the Repository code. AFTER you complete that then you can consider the following
1. Are threads involved?
2. Is there any point to using a singleton?
If the answer to the first is no and the answer to the second is yes then you can use a singleton.