Note that there are some explanatory texts on larger screens.

plurals
  1. PODifferent schema name on correlation table - Entity Framework
    primarykey
    data
    text
    <p>Is it possible to have a different schema name on correlation tabels than [dbo]?</p> <p>I'm using code first.</p> <p>Example:</p> <p>ApplicationRole.cs</p> <pre><code>public class ApplicationRole { public Guid ApplicationRoleId { get; set; } public string Name { get; set; } public virtual ICollection&lt;ADGroup&gt; ADGroups { get; set; } } </code></pre> <p>ADGroup.cs</p> <pre><code>public class ADGroup { public Guid ADGroupId { get; set; } public string Name { get; set; } public virtual ICollection&lt;ApplicationRole&gt; ApplicationRoles { get; set; } } </code></pre> <p>ApplicationRoleConfiguration.cs</p> <pre><code>public class ApplicationRoleConfiguration : EntityTypeConfiguration&lt;ApplicationRole&gt; { public ApplicationRoleConfiguration() { ToTable("T_ApplicationRoles", "LabConfig"); this.HasKey(a =&gt; a.ApplicationRoleId); this.Property(t =&gt; t.ApplicationRoleId) .HasColumnName("ApplicationRole_GUID") .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); } } </code></pre> <p>ADGroupConfiguration.cs</p> <pre><code>public class ADGroupConfiguration : EntityTypeConfiguration&lt;ADGroup&gt; { public ADGroupConfiguration() { ToTable("T_ADGroups", "LabConfig"); this.HasKey(a =&gt; a.ADGroupId); this.Property(t =&gt; t.ADGroupId) .HasColumnName("ADGroup_GUID") .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); // correlation table should also get schema [LabConfig] this.HasMany(o =&gt; o.ApplicationRoles) .WithMany(r =&gt; r.ADGroups) .Map(m =&gt; { m.MapLeftKey("ADGroup_GUID"); m.MapRightKey("ApplicationRole_GUID"); ToTable("T_ApplicationRoleADGroups", "LabConfig"); }); } } </code></pre> <p>But the result on the database is always:</p> <ul> <li>[LabConfig].[T_ADGroups]</li> <li>[LabConfig].[T_ApplicationRoles]</li> <li>[<strong>dbo</strong>].[ApplicationRoleADGroups]</li> </ul> <p>Any ideas? I spent hours for this to work with my desired schema without any success.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload