title: Flutter, Sqflite - DatabaseException(no such table: Project...)
body: <p>So I have a class DBProvider, which is creating a new instance whenever it hasn't been initialized yet.
  The database currently contains 8 tables that are created in 1 query (the same thing happens when there is only 1 table). Then I'm trying to retrieve one of the tables, but it fails on &quot;no such table&quot; every time.</p>
  <p>This is shorter version of my DBProvider</p>
  <pre><code>class DBProvider {
    DBProvider._();
  
    static final DBProvider db = DBProvider._();
    static Database _database;
  
    Future&lt;Database&gt; get database async {
      if (_database != null)
        return _database;
  
      // if _database is null we instantiate it
      _database = await initDB();
      return _database;
    }
  
    static const tableProject = &quot;&quot;&quot;
    CREATE TABLE IF NOT EXISTS Project (
          id TEXT PRIMARY KEY,
          managerId TEXT,
          consultantID TEXT
          name TEXT,
          description TEXT,
          created TEXT,
          deadline TEXT
        );&quot;&quot;&quot;;
    static const tableAudit = &quot;&quot;&quot;
    CREATE TABLE IF NOT EXISTS Audit (
          id TEXT PRIMARY key,
          projectId TEXT,
          timeTrackId TEXT,
          jsonChanges TEXT,
          date TEXT,
          employeeId TEXT
        );&quot;&quot;&quot;;
    static const tableEmployee = &quot;&quot;&quot;
    CREATE TABLE IF NOT EXISTS Employee (
          id TEXT PRIMARY key,
          fullName TEXT,
          managementLogonAccess INTEGER
        );&quot;&quot;&quot;;
    static const tableJobPosition = &quot;&quot;&quot;
    CREATE TABLE IF NOT EXISTS JobPosition (
          id TEXT PRIMARY KEY,
          name TEXT
        );&quot;&quot;&quot;;
    static const tableWorkType = &quot;&quot;&quot;
    CREATE TABLE IF NOT EXISTS WorkType (
          id TEXT PRIMARY key,
          name TEXT
        );&quot;&quot;&quot;;
    static const tableAssignedJobPosition = &quot;&quot;&quot;
    CREATE TABLE IF NOT EXISTS AssignedJobPosition (
          employeeId TEXT,
          positionId TEXT
        );&quot;&quot;&quot;;
    static const tableTimeTrack = &quot;&quot;&quot;
    CREATE TABLE IF NOT EXISTS TimeTrack (
          id TEXT PRIMARY key,
          timeSpan INTEGER,
          employeeId TEXT,
          projectId TEXT,
          workType TEXT,
          note TEXT,
          date TEXT
        );&quot;&quot;&quot;;
    static const tableAllowedWorkType = &quot;&quot;&quot;
    CREATE TABLE IF NOT EXISTS AllowedWorkType (
          projectId TEXT,
          workTypeId TEXT
        );&quot;&quot;&quot;;
  
    Future&lt;Database&gt; initDB() async {
      print(&quot;initDB executed&quot;);
      //Directory documentsDirectory = await getApplicationDocumentsDirectory();
      String path = join(await getDatabasesPath(), &quot;core.db&quot;);
      await deleteDatabase(path);
      return await openDatabase(path, version: 2,
          onCreate: (Database db, int version) async {
        await db.execute(
            tableEmployee +
                tableAudit +
                tableProject +
                tableJobPosition +
                tableWorkType +
                tableAssignedJobPosition +
                tableTimeTrack +
                tableAllowedWorkType
        );
      });
    }
  
   
    ///get all Projects
    Future/*&lt;List&lt;Project&gt;&gt;*/ getAllProjects() async{
      final db = await database;
      return await db.query(&quot;Project&quot;);
      /*var res =
      return res.isNotEmpty ? res.map((c) =&gt; Project.fromMap(c, false)).toList() : [];*/
    }
  </code></pre>
  <p>Afterwards I call it in main like following:</p>
  <pre><code>var res = await DBProvider.db.getAllProjects();
      print(res);
  </code></pre>