Search for existing suggestions

Support SQL Server Schemas/Owners as CLR namespace/classes

SQL Server schemas (or owners) should reflect into CLR namspace branches or inner classes.

If you have Sales.Customer and Orders.Customer on the database, that shouldn't be Customer and Customer1.

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

We’ll send you updates on this idea

Paulo Morgado shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

3 comments

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

    I have this requirement for Database first from the designer, I have several application that are on legacy databases. At the moment I have to create several models, and sometimes extra models just to allow certain queries. It would be great to have a switch where we could map Schema Name to Namespace.

    Steve

  • sjnaughton commented  ·   ·  Flag as inappropriate

    I would like the option to separate Entities base on schema, e.g. I have a single database that has two sets of tables that have the same names but are in different Schemas it would be nice to create a single data model that does this. At the moment I have to create different models for each schema is separate folder to get what I want but then I cant have relationships between them.

    Thanks
    Steve

  • Konstantin Tarkus commented  ·   ·  Flag as inappropriate

    With Code First development that's should be pretty easy to implement. Here is an example:

    // User.cs

    namespace App.Data.Models.Membership
    {
    public class User { }
    }

    // DataContext.cs

    using Membership = App.Data.Models.Membership;

    namespace App.Data
    {
    public DataContext : DbContext
    {
    public DbSet<Membership.User> Users { get; set; }

    protected override void OnModelCreating(ModelBinder binder)
    {
    binder.Configurations.Add(new CustomEntityTypeConfiguration<DataContext>());

    base.OnModelCreating(binder);
    }
    }
    }

Feedback and Knowledge Base