Search for existing suggestions

I should be able to set the default db schema name that will be used

If I create a new application and therefore a new DBContext, the template should have a way for me to set the db schema name I would like to use. I shouldn't have to rename tables later on to achieve this.

This will allow me to run multiple applications / clients from the same database.

9 votes
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)

We’ll send you updates on this idea

Gordon shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

4 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Alex Ford commented  ·   ·  Flag as inappropriate

    This issue threw me through a loop on my shared host. By default SQL users I create on my shared host server have their default schema set the same as the username. EF was creating all my tables under that default schema but then it was looking for them under "dbo" schema.

    We at least need a fluent api call to change this default schema. Currently the only way to do it in code is to use the fluent api and specify table mappings for EVERY table, passing in the schema in an overload of ToTable().

    Easier fix for me was to run "ALTER USER username WITH DEFAULT_SCHEMA=dbo". Now all my tables are created under "dbo", but if I actually cared about my schemas then this would really suck. I definitely vote for this to happen.

  • Gordon Rudman commented  ·   ·  Flag as inappropriate

    This will allow me to use the ASP MVC 4 Memberships with EF Code First.
    MVC 4 memberships creates tables like dbo.Profiles, dbo.Users, dbo.Roles...
    If another website of mine naturally has an entity with the same name I'm stuck, or I have to use some other less natural name.

    An example is a user Profile, each website can have a different view of what makes up a user profile (eg, name, location, date of birth...) and it wouldn't be appropriate to add all this info to the membership dbo.Profiles table.

    Without being about to set the schema name from the start the migration scripts won't be able to run, because the table name already exists in the dbo schema.

Feedback and Knowledge Base