SQL 没有这样的逻辑错误 table:将 xaf 标准安全性移植到 Sqlite

SQL logic error no such table: porting xaf standard security to Sqlite

我正在尝试使用 SQLite 创建一个 XAF Winforms 项目 运行。 我正在使用 Entity Framework 6 Code First with Standard Security。

当我运行我得到的项目

SQL logic error
no such table: PermissionPolicyUsers

   at System.Data.SQLite.SQLite3.Prepare(SQLiteConnection cnn, String strSql, SQLiteStatement previous, UInt32 timeoutMS, String& strRemain)
   at System.Data.SQLite.SQLiteCommand.BuildNextCommand()
   at System.Data.SQLite.SQLiteCommand.GetStatement(Int32 index)
   at System.Data.SQLite.SQLiteDataReader.NextResult()
   at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
   at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.SQLite.SQLiteCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
   at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)

在我的 DbContext 中

public class Things5DbContext : DbContext {
    public Things5DbContext(String connectionString)
        : base(new SQLiteConnection() { ConnectionString = connectionString }, true)

    {
    }
    public Things5DbContext(DbConnection connection)
        : base(connection, false) {
    }
    public Things5DbContext()
        : base("name=ConnectionString") {
    }
    public DbSet<ModuleInfo> ModulesInfo { get; set; }
    public DbSet<PermissionPolicyRole> Roles { get; set; }
    public DbSet<PermissionPolicyTypePermissionObject> TypePermissionObjects { get; set; }
    public DbSet<PermissionPolicyUser> Users { get; set; }
    public DbSet<ModelDifference> ModelDifferences { get; set; }
    public DbSet<ModelDifferenceAspect> ModelDifferenceAspects { get; set; }
}

我想如果我可以访问 PermissionPolicyUser class 我可以应用一个属性

[Table("Users")]  and rename the DbSet to PermissionPolicyUsers

但是 class 是在 Dev Express 库中定义的

DevExpress.Persistent.BaseImpl.EF.PermissionPolicy

原来数据库中没有创建表。

我尝试了以下但没有帮助

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.Entity<PermissionPolicyRole>().ToTable("PermissionPolicyRoleBases");
    modelBuilder.Entity<PermissionPolicyUser>().ToTable("PermissionPolicyUsers");
    modelBuilder.Entity<PermissionPolicyTypePermissionObject>().ToTable("PermissionPolicyTypePermissionObjects");

    base.OnModelCreating(modelBuilder);
}

我忘了修复初始值设定项

  protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        var sqliteConnectionInitializer = new SqliteCreateDatabaseIfNotExists<Things6DbContext>(modelBuilder);
        Database.SetInitializer(sqliteConnectionInitializer);
    }