SQLite.SQLiteException: duplicate column name
See original GitHub issueI’m having the following error in my application, using Xamarin in Android: SQLite.SQLiteException: duplicate column name IdSettings.
Here is my code:
private Database()
{
this.connection = new SQLiteConnection(DatabasePath);
this.Connection.CreateTable<Settings>();
this.Connection.CreateTable<Profile>();
this.Connection.CreateTable<Stat>();
this.Connection.CreateTable<Crest>();
this.Connection.CreateTable<MatchTeam>();
this.Connection.CreateTable<Match>();
this.Connection.CreateTable<Media>();
this.Connection.CreateTable<DbInfo>();
}
And here is the stack trace from Android:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
... 1 more
Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: SQLite.SQLiteException: duplicate column name: IdSettings
at SQLite.SQLite3.Prepare2 (SQLitePCL.sqlite3 db, System.String query) [0x0001e] in <filename unknown>:0
at SQLite.SQLiteCommand.Prepare () [0x00011] in <filename unknown>:0
at SQLite.SQLiteCommand.ExecuteNonQuery () [0x00012] in <filename unknown>:0
at SQLite.SQLiteConnection.Execute (System.String query, System.Object[] args) [0x00040] in <filename unknown>:0
at SQLite.SQLiteConnection.MigrateTable (SQLite.TableMapping map) [0x000db] in <filename unknown>:0
at SQLite.SQLiteConnection.CreateTable (System.Type ty, CreateFlags createFlags) [0x00176] in <filename unknown>:0
at SQLite.SQLiteConnection.CreateTable[T](CreateFlags createFlags) [0x00000] in <filename unknown>:0
at FifaSeasons.Entities.Database..ctor () [0x0001d] in <filename unknown>:0
at FifaSeasons.Entities.Database.get_Instance () [0x00022] in <filename unknown>:0
at FifaSeasons.Entities.Settings.Load () [0x00000] in <filename unknown>:0
at FifaSeasons.App..ctor () [0x00006] in <filename unknown>:0
at FifaSeasons.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00023] in <filename unknown>:0
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00011] in <filename unknown>:0
at (wrapper dynamic-method) System.Object:77f7d68d-0e63-4fa1-ba05-91ac6f4e8d28 (intptr,intptr,intptr)
at md57f9709086b0c248507ed1071a2b22cc2.MainActivity.n_onCreate(Native Method)
at md57f9709086b0c248507ed1071a2b22cc2.MainActivity.onCreate(MainActivity.java:28)
at android.app.Activity.performCreate(Activity.java:6021)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2284)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5354)
... 4 more
This occurs in the first run of the application, and I think that the method MigrateTable should not run.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Duplicate column name on SQLite upgrade for a new column
I've been getting an inconsistent, non-reproducible crash upon users upgrading to a new version of the local SQLite DB when updating the app....
Read more >ALTER TABLE ADD COLUMN problem
As things stand, with "duplicate column" I get error numner 1 (generic error, not too useful) and a message such as "duplicate column...
Read more >SQLiteException - Duplicate column name [227231447]
I am assuming it happens because I use on-demand initialization of the WorkManager (faster app startup times) and my app is multi-process (main ......
Read more >SQLite.SQLiteException: duplicate column name id in v1. ...
This works fine up to v1.3.2 but in v1.3.3 it causes an SQLite.SQLiteException: duplicate column name id. I'm using current Visual Studio ...
Read more >crash in android.database.sqlite.SQLiteException ...
SQLiteException : duplicate column name: touchIcon (code 1): , while compiling: ALTER TABLE metadata ADD COLUMN touchIcon STRING at android.database.sqlite.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I will try adding the
[Preserve]
attribute to the assembly to help, but first I need to repro.https://developer.xamarin.com/guides/ios/advanced_topics/linker/#Preserving_Code
This is still not a great solution but:
from: https://forums.xamarin.com/discussion/65328/sqlite-duplicate-column-name-exception-on-device-but-not-on-simulator