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). Ca开发者_C百科stle 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?
You can also use the DbContext to get the Sql DDL.
string sqlscript = (context as IObjectContextAdapter).ObjectContext.CreateDatabaseScript();
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
i think the Entity Designer Database Generation Power Pack is probably what you're looking for.
精彩评论