Referenced table is not in dictionary - asp.net

When I scaffold my database get the following error:
Referenced table `contentcategory` is not in dictionary.
Referenced table `contentcategory` is not in dictionary.
Referenced table `contenttype` is not in dictionary.
Referenced table `content` is not in dictionary.
I Use Mysql and Pomelo.EntityFrameworkCore.MySql

This is very likely to be a casing issue, where MySQL assumes the table name to be contentcategory for the reference, while it is actually something like ContentCategory.
We have a pull request for this open since April, that looks abandoned by the original contributor.
I will fix the PR and merge it, so that the workaround for this issue will be part of our nightly builds as of tomorrow.
The linked PR also contains the information of how this issue can arise:
Okay, that is in line with what I experienced as well. So manually (either by writing the name in the GUI or by using an ALTER TABLE statement directly) adding a reference with different casing (on a server with case insensitive file name handling) or disabling SQL Identifiers are Case Sensitive [in MySQL Workbench] can lead to this result.
Technically, this is a MySQL or Workbench bug, but we will implement a workaround for it anyway.

Related

Persistent error condition relating to Sqlite metadata

I've run into a very puzzling problem regarding a table in a Sqlite database.
The table has this simple DDL definition:
CREATE TABLE [MATable2] ([ID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[AName] VARCHAR(20), [AMemo] MEMO)
Using XE6, DBExpress and v.3.8.5.0 of sqlite3.dll I've created a project
to investigate another SO q. The project (32-bit target) is deliberately as minimalist as I could make it, i.e. I've just pulled off the component palette a SqlConnection,
SqlQuery (which just does a 'SELECT * from [MATable2]'), DataSetProvider, CDS,
DataSource, DBGrid and DBNavigator wired up in left-to-right order as it were.
The code is equally minimalist, and I don't think I need show it because my
problem isn't with the code per se, which works fine.
The problem I've been getting is this: Every now and then, usually after I've made
some blunder that generates an exception (like calling CDS.Refresh in its ApplyUpdates event) the project (I would say "or its server" if the server in Sqlite's case weren't just
a dll) gets into an "error condition" which persists across restarting the XE6 IDE and
rebooting the machine. It manifests itself by the SqlQuery.Open generating an exception
complaining about a mismatch between the expected and actual field types, e.g. in the
case of the ID field, the exception will report that it was expecting a WideMemo field but received a LargeInt one instead - it's as if there is something off by one in the table's metadata as received by the SqlQuery.
Thinking this condition might be DBX-specfic, and something to do with Sqlite column
types really being thinly-disguised memo fields, I created a FireDac equivalent
project and that gets the error condition, too. Then, the condition clears,
as mysteriously as it appeared, usually after I delete the dataset components +
TFields and replace them.
So, my question is, does anyone know where can the error cause could be persisting, I mean
such that it survives IDE restarts and machine reboots? My first thought was in the DFM, because of what I've said about how it spontaneously clears. Next, I suspected the database itself, but it seems perfectly tickety-boo accessed, queried and recreated using two independent Sqlite utilities, Sqlite Expert and the Sqlite Manager add-in for Firefox. The OS reports the disk as w/out errors. I've looked for persisted info that might be the cause, in Ini files and the Registry, but found nothing obvious.

Can I change the type of an index on the fly without re-creating the table?

I have always used a custom implementation of SQLite, and it had the "LATIN_NOCASE" collation.
I am now using System.Data.SQLite, and it doesn't have this collation, as I have found out now.
I would therefore like to change all indexes from LATIN_NOCASE to NOCASE.
Can I somehow do that with one line of code, or do I have to recreate the table / the indexes?
SQLite is designed as a lightweight, embedded database where large changes to the database are not supposed to happen at runtime, so it has no ALTER INDEX command: http://www.sqlite.org/lang.html.

Base directory and schema_version

I just tested the commandline tool and I was able to migrate my database schema changes (DDL scripts) as expected. But I had to move all my scripts under the sql dir.
Is there a way to point flyway to the directory where my real scripts will reside (git or svn repository)? Looks like flyway.locations is only for relative paths.
The schema_version table name and column names are all created in lower case in my database (Oracle). The vast majority of people using Oracle are used to upper case object names and column names (default in Oracle). I found a property in the config file to set my own table name. Is there any to get flyway to use upper case for column names?
I checked the data inserted into version_schema after my test run. All look good except that the first character of the "script" column seem to be removed.
My prefix is "db_". Here is what I see in schema_version,
SQL> select "script" from schema_version;
script
b_1_0__test10.sql
b_1_1__test10.sql
b_1_0_1__test10.sql
atabase/db_2012_11_20__query.sql
<< Flyway Init >>
Lots of questions here (It's easier if you keep them separate). I'll try my best to answer them:
Not currently supported. See https://github.com/flyway/flyway/issues/108 . Symlinking can be used as a workaround.
No, there is no configuration property for the column names. The schema_version table is private to Flyway and not meant for outside consumption.
This sounds like a bug. Please file an issue containing your configuration (OS + version, DB + version, Flyway version, config file contents) and exact steps to reproduce.

Can not make generateChangeLog working in liquibase to export data from existing database

I read some similar questions, but I still can not figure out how to export data or schemas from an exiting database using liquibase. The database i am using is sqlite, and I always got problem.
java -jar liquibase-1.9.3.jar --driver=org.sqlite.JDBC --classpath=lib/sqlite-jdbc-3.7.2.jar --changeLogFile=test.data --url=jdbc:sqlite:test.db --diffTypes="data" generateChangeLog
the error is: Migration Failed: no such column: 'DECIMAL_POINTS'
I just have a testing table with 2 fields: ID (integer type), and name (VARCHAR type).
Can somebody help? Thanks.
I couldn't find more examples about using liquibase with sqlite database. So, I tested and figured out by myself, and commented below:
You need to pick up right jdbc engine for liquibase, when I changed sqlitejdbc engine from sqlite-jdbc-3.7.2.jar to sqlitejdbc-v056.jar (http://www.zentus.com/sqlitejdbc/), it works. So it is important to pick up right one.

SQLite Modify Column

I need to modify a column in a SQLite database but I have to do it programatically due to the database already being in production. From my research I have found that in order to do this I must do the following.
Create a new table with new schema
Copy data from old table to new table
Drop old table
Rename new table to old tables name
That seems like a ridiculous amount of work for something that should be relatively easy. Is there not an easier way? All I need to do is change a constraint on a existing column and give it a default value.
That's one of the better-known drawbacks of SQLite (no MODIFY COLUMN support on ALTER TABLE), but it's on the list of SQL features that SQLite does not implement.
edit: Removed bit that mentioned it may being supported in a future release as the page was updated to indicate that is no longer the case
If the modification is not too big (e.g. change the length of a varchar), you can dump the db, manually edit the database definition and import it back again:
echo '.dump' | sqlite3 test.db > test.dump
then open the file with a text editor, search for the definition you want to modify and then:
cat test.dump | sqlite3 new-test.db
As said here, these kind of features are not implemented by SQLite.
As a side note, you could make your two first steps with a create table with select:
CREATE TABLE tmp_table AS SELECT id, name FROM src_table
When I ran "CREATE TABLE tmp_table AS SELECT id, name FROM src_table", I lost all the column type formatting (e.g., time field turned into a integer field
As initially stated seems like it should be easier, but here is what I did to fix. I had this problem b/c I wanted to change the Not Null field in a column and Sqlite doesnt really help there.
Using the 'SQLite Manager' Firefox addon browser (use what you like). I created the new table by copying the old create statement, made my modification, and executed it. Then to get the data copied over, I just highlighted the rows, R-click 'Copy Row(s) as SQL', replaced "someTable" with my table name, and executed the SQL.
Various good answers already given to this question, but I also suggest taking a look at the sqlite.org page on ALTER TABLE which covers this issue in some detail: What (few) changes are possible to columns (RENAME|ADD|DROP) but also detailed workarounds for other operations in the section Making Other Kinds Of Table Schema Changes and background info in Why ALTER TABLE is such a problem for SQLite. In particular the workarounds point out some pitfalls when working with more complex tables and explain how to make changes safely.

Resources