In the EF tutorials described the work with Model-First approach in the following way:
But how it could be delivered to the customers? The database must be created on customers side automatically on program launch and it must be deleted when the customer select some menu action. How above behavior could be implemented via EF?
Your Model-First approach should have create a DbContext derived class, something like class MyModelContainer : DbContext
.
In the startup phase of your app, do something like this:
using(var ctx = new MyModelContainer())
{
ctx.Database.CreateIfNotExists();
}
similarly, when you want to delete it (first close all connections):
using(var ctx = new MyModelContainer())
{
ctx.Database.Delete();
}