How does Database.SetInitializer actually work? (EF code-first create database and apply migrations using several connection strings)

前端 未结 2 582
情话喂你
情话喂你 2021-01-03 04:48

I am trying to write a method to create a database and run migrations on it, given the connection string.

I need the multiple connections because I record an audit

2条回答
  •  盖世英雄少女心
    2021-01-03 05:40

    You can supply a configuration in the MigrateDatabaseToLatestVersion constructor. If you set the initializer in the DbContext you can also pass a 'true' to use the current connection string.

提交回复
热议问题