none
Specify database schema RRS feed

  • Question

  • Hello,

    I use Code First in EF 5.

    I know that I can specify a database schema when I specify a table name (in "ToTable()" and  Map( x => ToTable() )".

    Unfortunately, when I do not do this, "dbo." is assumed, which is dead wrong in case of Oracle. (This IMHO is a bug).

    Question:

    - Can I specify the database Schema of all my tables at some general place, e.g. DBModelBuilder?

    - Or can I make the generated SQL do not use a Schema prefix at all (would be best solution) ?

    I did not find any information about database schema at all.

    Regards
    daProgramma

    Thursday, October 4, 2012 12:54 PM

Answers

  • Hi DaProgramma,

    Sorry for misunderstanding. What name will be created depends on the what action data provider takes. I cannot try Oracle on my side, but for SQL Server, if I do not specify the name, the name of database will be the name of connection string or project name + context name. If you want to change the name of the database that is created for you, one of the ways to configure it is to alter the constructor on your DbContext, specifying the new database name. For more information, please refer to this page: http://blogs.msdn.com/b/adonet/archive/2010/12/06/ef-feature-ctp5-code-first-walkthrough.aspx

    Scroll down to point 7.

    Have a nice day.


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Alexander Sun Tuesday, October 23, 2012 8:25 AM
    Wednesday, October 10, 2012 8:26 AM

All replies