Cannot create a table without columns
Hello,
I am getting this error when I am calling the method db.CreateTable<Student>();
I have student class like this : public class Student { [PrimaryKey, AutoIncrement] public int LocalId { get; set; } public string StudentId { get; set; } public string SakshamMitraID { get; set; } public int ID { get; set; } public string Name { get; set; } }
and final code for creating the table
this.DBPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "AttendanceModel.db");
// Handle when your app starts
using (var db = new SQLiteConnection(this.DBPath, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite))
{
// Create the tables if they don't exist
db.CreateTable<Student>();
}
Aren't you suppose to supply some extra info to CreateTable()? I usually use it like connection.CreateTable<Student>();
I don't see how connection.CreateTable(); can just succeed since it has no idea about what kind of table structure you want to create. Did you configure a database/connection to only handle certain objects (like in some other type of database) before calling CreateTable()? I honestly don't think SQLite supports that but asking just in case you didn't show some part of your code.
this.DBPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "AttendanceModel.db");
using (var db = new SQLiteConnection(this.DBPath, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite)) { //Create the tables if they don't exist db.CreateTable<Student>(); }
Below are the tables : public class Student { [PrimaryKey, AutoIncrement] public int LocalId { get; set; } public string StudentId { get; set; } public string SakshamMitraID { get; set; } public int ID { get; set; } public string Name { get; set; } }
On Fri, Sep 20, 2019 at 3:31 PM Yi Ding [email protected] wrote:
Aren't you suppose to supply some extra info to CreateTable()? I usually use it like connection.CreateTable<Student>();
I don't see how connection.CreateTable(); can just succeed since it has no idea about what kind of table structure you want to create. Did you configure a database/connection to only handle certain objects (like in some other type of database) before calling CreateTable()? I honestly don't think SQLite supports that but asking just in case you didn't show some part of your code.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/praeclarum/sqlite-net/issues/863?email_source=notifications&email_token=ACFBIVXJABDBSA5MXBKFDBTQKSNQXA5CNFSM4IMW5TFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7GHCJI#issuecomment-533492005, or mute the thread https://github.com/notifications/unsubscribe-auth/ACFBIVVNZDNDLPY6FVJ7MLLQKSNQXANCNFSM4IMW5TFA .
Hi, your code looks fine. Can you report which version you're hitting this on?
sqlite-net-pcl version 1.5.231
On Sat, Sep 21, 2019 at 11:43 PM Frank A. Krueger [email protected] wrote:
Hi, your code looks fine. Can you report which version you're hitting this on?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/praeclarum/sqlite-net/issues/863?email_source=notifications&email_token=ACFBIVUTZL7UVRDBQHTR7UTQKZP5NA5CNFSM4IMW5TFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7IW5HY#issuecomment-533819039, or mute the thread https://github.com/notifications/unsubscribe-auth/ACFBIVTI56HWBCRXBMPP4NLQKZP5NANCNFSM4IMW5TFA .
Hi @kumarsachin031 Is that Issue fixed?
I also have the same problem, it still hasn't been solved?
I had this same issue and was able to pinpoint the issue to linker stripping away class properties and therefore in my Unity project I had to add [UnityEngine.Scripting.Preserve] above the class description to prevent this from happening. More information here for other environments https://stackoverflow.com/questions/30059344/table-has-no-public-columns-only-on-real-device
I leave this comment here in case it helps others.
Hi there, Is that Issue fixed?
<PackageReference Include="sqlite-net-pcl" Version="1.7.335" />
<PackageReference Include="Xamarin.Forms" Version="4.7.0.968" />
<TargetFramework>netstandard2.1</TargetFramework>
I was going through the same here. Turned out sqlite-net doesn't support private set properties, and I had a table class with all private set props. That was causing the "no properties" exception when trying to create the table.
I run into this error, when I have a method in my Table, that uses some query methods, like Single(), directly on a list with children.
Example:
public string GetTextProjectPartOrderValues(int part_id) { return this.TextProjectParts.Single(tpp => tpp.Id == part_id).OrderValuesCsv; }