Reputation: 17216
I'm creating an application that uses Entity Framework 4 as the ORM. I'm using the designer and have generated the Domain.emdx.sql file to create the database.
So far, I've just run that edmx in sqlserver manually to create the db, but I'm now working on a lightweight installer and I'd like to connect to the db if it exists and run the sql script to create the database, after which I'll use my repositories to insert all of the default values that the db should be populated with.
I would like to be able to load the edmx.sql file so that it will always take the most current changes without having to copy the contents of that file into some resource manually, but I can't seem to find out how to get at its contents in code. It's not in the build folder and it doesn't appear to be directly accessible in code.
How might I do that?
Upvotes: 0
Views: 581
Reputation: 122032
You can try using the CreateDatabaseScript method. It will provide you with the script.
However, looks like you need the CreateDatabase method of the ObjectContext class, this method will simply create a database.
Upvotes: 1