Reputation: 519
Database.SetInitializer()
works great for testing, but I need the SQL output in a file for working in a production environment (DBAs aren't going to run a program to create the DB). Castle ActiveRecord make output to a file easy with ActiveRecordStarter.GenerateCreationScripts()
. If there's a similar method in EF, I'm unable to find any mention of it. Is this doable?
Upvotes: 3
Views: 2034
Reputation: 91
You can also use the DbContext to get the Sql DDL.
string sqlscript = (context as IObjectContextAdapter).ObjectContext.CreateDatabaseScript();
Upvotes: 9
Reputation: 11987
i think the Entity Designer Database Generation Power Pack is probably what you're looking for.
Upvotes: 0
Reputation: 272
Well you could run the Database.SetInitializer() method to create the initial database for you and then once you are satisfied with the database schema then you could possibly use something like SQL Server Management Studio to generate the script from the database
Upvotes: 3