entity framework - Stop a referenced dll from running migrations -


i have solution web application. application uses entity framework , code first. have second project, console application. console application shares assembly hold migrations.

is there way console application should never run migrations? happen console application contain newer version has not yet been deployed in web application. make sure there no risk console ruin web application. better have console failing updating database.

set database initialiser null in dbcontext constructor:

public class consolecontext : dbcontext {      public consolecontext()         : base("name=" + config.connectionstringname)     {         // prevent attempt initialize database context         database.setinitializer<dtocontext>(null);     } } 

alternatively, in web application:

protected void application_start() {     database.setinitializer<mydbcontext>(        new migratedatabasetolatestversion<mydbcontext, migrations.configuration>()); } 

and in console application:

protected void application_start() {     database.setinitializer<dtocontext>(null); } 

and, doubly certain, use 2 different database users. web application need db_datareader, db_datawriter , db_ddladmin roles if you're using sql server. console application should in db_datareader , db_datawriter roles prevent changing database schema


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -