locked
The type or namespace name 'SQLite' could not be found (are you missing a using directive or an assembly reference?) RRS feed

  • Question

  • Trying to get sql server compact up and running. I connected to a sqlite database and atuo generated the model.cs code.

    however, I get the following error.

    Error    1    The type or namespace name 'SQLite' could not be found (are you missing a using directive or an assembly reference?)    C:\Users\kenny\Documents\Visual Studio 2013\Projects\WindowsFormsApplication2\WindowsFormsApplication1\Model.cs    3

    Any help is greatly appreciated. Please provide some detail as I am novice. 

    Thanks

    Friday, February 6, 2015 3:45 AM

Answers

  • Could you pls qualify "no luck" ??

    Adding Model.cs to a project and the blog post you Refer are two different Things, as I tried to point out earlier.

    You can use the ADO.NET provider with EF for dekstop app (system.Data.SQLite). For Windows Store and Phone apps, ADO.NET is not available, so you can use the sqlite-net files instead.

    The sqlite-net files contain the  SQLIte namespace.


    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    Monday, February 9, 2015 4:18 PM

All replies

  • Trying to get sql server compact up ... The type or namespace name 'SQLite' could not be found

    SQL Server Compact (CE) is something different the SQLLite (http://www.sqlite.org/) ; so which one do you want to use and for which one have you added a reference?

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Friday, February 6, 2015 8:33 AM
  • I connected to the sqlite database using SQL Server Compact CE, then I right click on the data source and I used SQL Server Compact CE auto-generate code to access the database it was calling out "using SQLite", which is not loaded in project and I can't figure out what I need to install to get it.

    Thanks

    Friday, February 6, 2015 2:14 PM
  • Ok so I got the past that problem. I had to add the package System.Data.SQLite Core in Manage NuGet.

    Then I changed the auto-generated code "using SQLite" to "using System.Data.SQLite".

    But now I have a new problem, it says "System.Data.SQLite.SQLiteConnection' does not contain a definition for 'CreateTable' "

    Here is the code

    //This code was generated by a tool.
    //Changes to this file will be lost if the code is regenerated.
    //using SQLite;
    using System;
    using System.Data.SQLite;
    using System.Data.SQLite.EF6;
    
    
    namespace WindowsFormsApplication2
    {
        public class SQLiteDb
        {
            string _path;
            public SQLiteDb(string path)
            {
                _path = path;
            }
            
             public void Create()
            {
    
                using (SQLiteConnection db = new SQLiteConnection(_path))
                {
                    db.CreateTable<servers>();
    
                  
                }
            }
        }
        
        public partial class servers
        {
            public Int64  server_name { get; set; }
            
            public Double  cpu_usage { get; set; }
            
        }
        
    }
    Any ideas why CreateTable is not available?

    Friday, February 6, 2015 4:44 PM
  • You cannot simply change the "using", as they are 2 different APIs. And as stated, System.Data.SQLite.SQLiteConnection' does not contain a definition for 'CreateTable' !


    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    • Proposed as answer by ErikEJMVP Monday, February 9, 2015 9:27 AM
    Monday, February 9, 2015 9:27 AM
  • Ok thanks for pointing that out. So back to the original problem, how do I get "SQLite" in the namespace. I followed your directions on http://erikej.blogspot.com/

    Using SQLite with the Entity Framework 6 designer - a troubleshooting guide

    but no luck

    Monday, February 9, 2015 3:48 PM
  • Could you pls qualify "no luck" ??

    Adding Model.cs to a project and the blog post you Refer are two different Things, as I tried to point out earlier.

    You can use the ADO.NET provider with EF for dekstop app (system.Data.SQLite). For Windows Store and Phone apps, ADO.NET is not available, so you can use the sqlite-net files instead.

    The sqlite-net files contain the  SQLIte namespace.


    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    Monday, February 9, 2015 4:18 PM
  • Hi, I´m having the exact same problem, wpf application, sqlite and ef6 installed. Any ideas? thx
    Friday, July 24, 2015 9:06 PM
  • ok, fixed, missing the sqllite-net package
    Friday, July 24, 2015 9:47 PM