Is it possible to use fluent migrator in application_start?

前端 未结 2 903
南笙
南笙 2021-01-30 08:46

I\'m using fluent migrator to manage my database migrations, but what I\'d like to do is have the migrations run at app start. The closest I have managed is this:



        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 09:14

    I have actually accomplished running migrations in the application_start however it is hard to tell from that code what could be wrong... Since it is open source I would just grab the code and pull it into your solution and build it to find out what the Execute method is complaining about. I found that the source code for Fluent Migrator is organized pretty well.

    One thing that you might have to be concerned about if this is a web app is making sure that no one uses the database while you are migrating. I used a strategy of establishing a connection, setting the database to single user mode, running the migrations, setting the database to multi user mode, then closing the connection. This also handles the scenario of a load balanced web application on multiple servers so 2 servers don't try to run migrations against the same database.

提交回复
热议问题