I have the following data table:
CREATE TABLE [dbo].[AuthorizeAttrib]
(
[Id] [UNIQUEIDENTIFIER] NOT NULL
, [ControllerName] [VARCHAR](100) NOT NULL
, [ActionName] [VARCHAR](100) NULL
, CONSTRAINT [PK_AuthorizeAttrib] PRIMARY KEY CLUSTERED ( [Id] ASC )
)
ON [PRIMARY];
In code I have the following:
public class StsDatabase : MembershipRebootDbContext<StsUser, StsGroup>
{
public StsDatabase() : this("name=MembershipReboot") { }
public StsDatabase(string name) : base(name) { this.RegisterUserAccountChildTablesForDelete<StsUser>(); }
public DbSet<AuthorizeAttrib> AuthorizeAttribs { get; set; }
public DbSet<Role> Roles { get; set; }
public DbSet<RuleSet> RuleSets { get; set; }
public DbSet<RuleSetRole> RuleSetRoles { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.ConfigureMembershipRebootUserAccounts<StsUser>();
modelBuilder.ConfigureMembershipRebootGroups<StsGroup>();
modelBuilder.Configurations.Add(new AuthorizeAttribMap());
modelBuilder.Configurations.Add(new RoleMap());
modelBuilder.Configurations.Add(new RuleSetMap());
modelBuilder.Configurations.Add(new RuleSetRoleMap());
}
}
And the AuthorizeAttribMap looks like:
public class AuthorizeAttribMap : EntityTypeConfiguration<AuthorizeAttrib>
{
public AuthorizeAttribMap()
{
// Primary Key
this.HasKey(t => t.Id);
// Properties
this.Property(t => t.ControllerName)
.IsRequired()
.HasMaxLength(100);
this.Property(t => t.ActionName)
.HasMaxLength(100);
// Table & Column Mappings
this.ToTable("AuthorizeAttrib");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.ControllerName).HasColumnName("ControllerName");
this.Property(t => t.ActionName).HasColumnName("ActionName");
}
}
I've even tried running with AND without the following:
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
Nothing seems to be working. When I break on the code before it executes and copy the SQL then run it in SQL Mangler it runs fine. The SQL produced by LINQ:
SELECT [Extent1].[Id] AS [Id]
, [Extent1].[ControllerName] AS [ControllerName]
, [Extent1].[ActionName] AS [ActionName]
FROM [dbo].[AuthorizeAttrib] AS [Extent1];
I am scratching my head as to what else would cause this challenge!
Any ideas?
答案 0 :(得分:0)
当构建/发布脚本运行时,引入了错误的web.config。仍然指向Dev DB而不是Security Dev DB。自我注意:总是检查web.configs。移动部件太多了!