Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Problem with sqlite and entity framework. please help!

Problem with sqlite and entity framework. please help!

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharphelpdatabasesqlitewpf
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neodeaths
    wrote on last edited by
    #1

    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

    S D 2 Replies Last reply
    0
    • N neodeaths

      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

      S Offline
      S Offline
      Sascha Lefevre
      wrote on last edited by
      #2

      I 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

      1 Reply Last reply
      0
      • N neodeaths

        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

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        In 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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups