DBMetal generates invalid class for sqlite_sequence
I am using DBLinq and DBMetal.exe to generate Linq-to-SQL classes other than SQLite database. Every time I use DBMetal to restore my DataContext, it generates a class for sqlite_sequence. The problem is that sqlite_sequence is not a proper table, so the class is not complete.
The question is, can DBMetal.exe do a better job of creating this class, or can I tell DBMetal to ignore this class?
Thank!
Here's my call to DBMetal.exe
.\DbMetal.exe /namespace:Namespace /provider:SQLite "/conn:Data Source=Datasource.db" /code:CodeFile.cs
Here's the actual generated SQL for sqlite_sequence (which is the system table):
CREATE TABLE sqlite_sequence(name,seq)
Here's the broken class that is generated (note the properties, name and seq, which have no datatype. This is the problem):
[Table(Name = "main.sqlite_sequence")]
public partial class SQLiteSequence : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private _name;
[DebuggerNonUserCode]
[Column(Storage = "_name", Name = "name", DbType = "")]
public Name
{
get
{
return _name;
}
set
{
if (value != _name)
{
_name = value;
OnPropertyChanged("Name");
}
}
}
private _seq;
[DebuggerNonUserCode]
[Column(Storage = "_seq", Name = "seq", DbType = "")]
public SEQ
{
get
{
return _seq;
}
set
{
if (value != _seq)
{
_seq = value;
OnPropertyChanged("SEQ");
}
}
}
public SQLiteSequence() {}
}
source to share
I figured out the way. It was a multi-step process, but there is a way to do exactly what I wanted.
I first generated the dbml from my database using the following command:
.\DbMetal.exe /namespace:Namespace /provider:SQLite "/conn:Data Source=Datasource.db" /dbml:CodeFile.dbml
Then I edited the dbml file (which is just an XML file of course) and removed the node for sqlite_sequence.
Finally, I generated the dbml.cs using this command:
.\DbMetal.exe /namespace:Namespace /provider:SQLite "/conn:Data Source=Datasource.db" /dbml CodeFile.dbml /code:CodeFile.dbml.cs
If I want to add a table or new columns, I will have to manually edit the dbml file, but now I have a control that I want to use for my SQLite DataContext!
source to share