How to Change the Schema name RRS feed

  • Question

  • Hi,

    I´m developing an ASP.NET MVC app that uses EF 4.1 Code First.

    I have to change the default schema name (dbo) to another name.


    I tried this:

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    	var schemaName = "SYSTEM";
    	modelBuilder.Entity<Account>().ToTable("TB_ACC_HOLDERS", schemaName);


    But it´s not working. When I get a new instance of my Context and call some of my Tables.. the generated query still with "dbo" schema name.


    Anyone have some idea to solve that?



    Yan Borowski
    Monday, November 21, 2011 4:37 PM


  • After a hard debug.. I found the error. My variable was being started in the constructor of the DataContext when running OnModelCreating arrived at the property was null. :-(
    Yan Borowski
    • Marked as answer by Yan Borowski Monday, November 21, 2011 7:46 PM
    Monday, November 21, 2011 7:46 PM