Problem with sqlite and entity framework. please help!
-
i am trying to get an sqlite project c# wpf application working with entity framework so that when i start my application and the sqlite file is missing it would create it. and the schema would come from the context just like entity framework codefirst this is what i got so far: my app.config
the following is my code for the entity and context. and how i initiate them:(i got them from reading tutorials)
class ChinookContext : DbContext
{
public DbSet Artists { get; set; }
public DbSet Albums { get; set; }
public ChinookContext(string filename)
: base(new SQLiteConnection()
{
ConnectionString -
i am trying to get an sqlite project c# wpf application working with entity framework so that when i start my application and the sqlite file is missing it would create it. and the schema would come from the context just like entity framework codefirst this is what i got so far: my app.config
the following is my code for the entity and context. and how i initiate them:(i got them from reading tutorials)
class ChinookContext : DbContext
{
public DbSet Artists { get; set; }
public DbSet Albums { get; set; }
public ChinookContext(string filename)
: base(new SQLiteConnection()
{
ConnectionStringI only have very little experience with EF but I think it should look like this in ChinookContext:
public DbSet<Artist> Artists { get; set; } public DbSet<Album> Albums { get; set; }
Otherwise those properties would have nothing to do with Artist and Album except the plural form of the names :-)
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
i am trying to get an sqlite project c# wpf application working with entity framework so that when i start my application and the sqlite file is missing it would create it. and the schema would come from the context just like entity framework codefirst this is what i got so far: my app.config
the following is my code for the entity and context. and how i initiate them:(i got them from reading tutorials)
class ChinookContext : DbContext
{
public DbSet Artists { get; set; }
public DbSet Albums { get; set; }
public ChinookContext(string filename)
: base(new SQLiteConnection()
{
ConnectionStringIn your ChinookContext class, remove the line you have in the OnModelCreating method. You don't need it. Also, your DbSet lines are bad. They should be:
public DbSet Artists { get; set; } public DbSet Albums { get; set; }
I HIGHLY suggest you don't take all of your information on EF from "some tutorial on the web" because you're missing a SHIT TON of information that these tutorials are not tell you. Pick up this book[^]. It's an older book, covering EF4, but it's better than the newer books out there that were released last year.
A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave Kreskowiak