Reputation: 411
I'm new to linq to entities.
In linqtosql you could do something like:
datacontext.CreateDatabase() to generate a database from the model in sql.
I'm wanting to do the same thing in linq to entities.
Say I have a class MyEntities which inherits from ObjectContect is there a similiar method?
Upvotes: 0
Views: 1049
Reputation: 21996
Take a look at the ModelBuilder class, there is a CreateModel method you can call on that.
Upvotes: 0
Reputation: 73123
Try this
// Create a builder and configure it
var builder = new ContextBuilder<MyContext>();
…
// Create a context
var mycontext = builder.Create(sqlConnection);
// Prepare the Context
if (!myContext.DatabaseExists())
myContext.CreateDatabase();
Upvotes: 1