entity framework - EF Code Migrations vs DB Scheme MS SQL and Oracle -


i using entity framework code fist migrations. have problem migrations bound concrete db schema. not such problem ms sql. in oracle: schema = user. data model bound db user can change.

when change default schema modelbuilder.hasdefaultschema("scheme_name") have generate new migration want able deploy app db user in oracle without having change code , recopmile project.

well, have multiple options achieving this, such as:

  1. using automatic migrations , making modelbuilder.hasdefaultschema(dbusername) functions use input parameter. has multiple disadvantages such not being able create migrations, instead every time automatically created has limits when deploying (not being able create scripts deploy etc.)
  2. you can implement custom migration step inherits createtableoperation class input not take ("schema_name.table_name" ...) "table_name" , dynamically gets schema name when run (see 1 of post creating custom migration operation general idea)
  3. retrieving user schema name , concatenating @ migrations.

if want fastest solution choose third option, this:

var schemaname = migrationhelper.getuserspecificschemaname(); createtable(string.format("{0}.people", schemaname),     c => new     {         id = c.int(nullable: false, identity: true),     }) .primarykey(t => t.id); 

because don't forget code in these migrations run other c# code, invoked through add-migration powershell script method.

for implementing getuserspecificschemaname can use ado.net retrieves oracle database.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -