Reputation: 19305
I can't seem to pass parameters to sqlite connection string ...
If I do:
public class MyDbContext : DbContext {
public DbSet<MyData> MyData { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
optionsBuilder.UseSqlite("Data Source=C:\\src\\mydb.db;");
}
}
Everything works fine. However if I change it to:
optionsBuilder.UseSqlite("Data Source=C:\\src\\mydb.db;Version=3;");
Then queries throw System.ArgumentException: 'Keyword not supported: 'version'.'
or if I change it to:
optionsBuilder.UseSqlite("Data Source=C:\\src\\mydb.db;Read Only=True;");
Then queries throw System.ArgumentException: 'Keyword not supported: 'read only'.'
what's wrong here ? how do I pass ie read only to sqlite ?
Upvotes: 0
Views: 2005
Reputation: 16838
Depending of the provider you are using certain keywords are not available. You can take a look at https://www.connectionstrings.com/sqlite/ for examples.If you are using Microsoft.Data.Sqlite then the connection string should use the keyword Mode=ReadOnly
From this reported issue:
We support the following keywords.
Keyword Values
Cache Private or Shared
Data Source The database file. Can be a URI filename.
Mode ReadWriteCreate, ReadWrite, ReadOnly, or Memory
Upvotes: 1