c# - Change table schema on middle table generated by Entity Framework -


i have got model m:n relation this:

[table("messages", schema = "public")] public class message {      public int id  { get; set; }     public virtual ilist<phone> phones{ get; set; }  }  [table("phones", schema = "public")] public class phone {      public int id  { get; set; }     public virtual ilist<message> messages{ get; set; }  } 

so ef generates middle table me... default schema of table not public (it need), still dbo. , gives me error: schema "dbo" not exist.

how can change table schema of messagephone table, without creating messagephone model class?

i think doable. have override onmodelcreating of dbcontext class , configure fluent api:

 protected override void onmodelcreating(dbmodelbuilder modelbuilder)  {      modelbuilder.entity<message>().hasmany<phone>(m => m.phones).withmany(p => p.messages).map            (             x =>                {                   x.totable("messagephone", "public");                }            );  } 

you have test this, not sure got of syntax right.. don't have vs here try it.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -