Let me explain the title.
I'm using Entity Framework Code First in an application (TestApp). For debugging purposes the TestApp connects to an SQLExpress database (central database server).
To keep things simple here, the database contains one table "Products" and the TestApp shows all "Products" from the database in a datagrid and TestApp can add/delete a "Product" or modify the ProductName.
public class Product {
public int ProductId { get; set; }
public string ProductName { get; set; }
}
public DbSet<Product> Products { get; set; }
I have for example 3 pc's where TestApp is installed and running (I'll call them Client_X). If I add a new "Product" via Client_1, than this is not directly visible in the TestApp on Client_2 and Client_3. Only when Client_2 and Client_3 fetch all the data again (manual refresh) than I see the newly added record.
What I want to know: How can I be aware of changes in the database via EF Code First? How would Client_2 and Client_3 get their datagrid automatically updated because a new item was added or removed?
I'm not sure if it is asked too much but a simple sample project or simple code to demonstrate this would be useful.
FYI: I'm fairly new to EF Code First. (I'm using .NET 4.0 and EF Code First 4.3.1)
Thanks in advance.
Scheme:
Client_3<
\
\
\
\
\>
Client_1 <---> [Central Database] <----> Client_2
Update/Edit:
Ok, it is clear that the Entity Framework itself doesn't do any syncing between multiple clients.
So i'll ask another question: I'm thinking of working the Client-Server way:
- A single server application which creates the database and uses the Entity Framework code first.
Multiple clients that communicate with that single server application.
What would now be the best way to make sure the clients use the same data and see eachothers updates/changes? (I would appreciate code samples.)