I have a few questions about creating a database from a model.
Is it possible to do this at runtime? I know you can generate the create sql in the designer but what about during runtime?
Can you create the DDL without creating a connection? Just kind of annoying to add a connect for the sole purpose of creating the DDL.
Is there an automatic way to handle alters? Like if I update the entity/table am I going to have to manually alter the table or is there anything to handle that?
Whats going on in EntityContext.CreateDatabase for sqlce? When I call it I have to recreate the context otherwise I cannot create the tables as they already ‘exist’. But they don’t really exist as any inserted data is not saved.
Absolutely. If your database doesn’t exist it will create it if you’ve specified
In your constructor:
What do you mean by recreating the context? If you specify Database. in your initialization, SQL CE database will be created.
Unfortunately the model becomes the initial source of changes. Future changes need to be made to both the database and the model.
Your SQL CE connect string is as such:
note that the ‘name’ should match the full namespace of the context class.