When developing an ASP.NET website with the Entity Framework, you can use an initialiser to drop and recreate the database when the model changes.
Take this example: I set up my project to drop and recreate the db under the Debug configuration, but not the Release.
I use Web Deploy 2.0, but, I see a potential issue, where I deploy to a production server, and forget to build the website with the configuration set to Release. Therefore the db may be dropped in production.
Is there a way to prohibit Visual Studio from publishing a website, based on certain criteria? eg destination server is X and the project is built in the Debug configuration
If you know the server name, you can write code to skip setting the database initializer in Global.asax
if(Server.MachineName=="skipServerName")
{//do not set the initalizer
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.