I cannot configure a working ODBC connection string for SQLite in aspsettings.json for .NET CORE Razor Pages

I have a Visual Studio 2017 .NET 2.2 Core Razor Pages project I have downloaded and installed the ODBC sqlite3 driver. I can see my sqlite database in Visual Studio Server Explorer and I can open tables and see rows. But for the life of me I cannot create a connection string that works.

I keep getting an error when clicking on the link to the page I want to display: "Course table not found". The error happens on the OnGetAsync :

namespace OESAC.Pages.Courses { public class IndexModel : PageModel { private readonly OESAC.Data.MyDbContext _context;

    public IndexModel(OESAC.Data.MyDbContext context)
        _context = context;
    }    public IList<CoursesViewModel> CoursesVM { get;set; }    public async Task OnGetAsync()
        //CoursesVM = await _context.Courses.ToListAsync();
        CoursesVM = await _context.Courses
            .Select(p => new CoursesViewModel
                OESACID = p.OESACID,
                CourseTitle = p.CourseTitle,
                Instructor = p.Instructor,
                Locations = p.Locations,

Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: Courses'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext() at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)

It happens no matter how I configure the ConnectionString in aspsetting.json.

I have tried every way I could find. Including just a plain path, a relative path, the string I can get when looking at the Connection I configured in VS that lets me see the tables and data. This is the connection string it gives me when configuring the ODBC driver for Sqlite:

"DefaultConnection": "Dsn=SQLite3 Datasource;database=J:\OESAC\Data\sqlite\oesac_new.db;stepapi=0;syncpragma=NORMAL;notxn=0;timeout=100000;shortnames=0;longnames=0;nocreat=1;nowchar=0;fksupport=0;oemcp=0;bigint=0;jdconv=0"

Here is a skinnier version I tried from this website (connectionstrings.com).

"DefaultConnection": "DRIVER=SQLite3 ODBC Driver;Database=J:\\OESAC\\Data\\oesac_new.db;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;"
edit delete
are you sure?
asked John A Davis

0 answers

Post an answer but please login first

Post Answer
  1. Please login to post answer

Similar Questions

Tagsfor this question

Forumall questions

This page is the archive of this page:https://www.connectionstrings.com/questions/54113/i-cannot-configure-a-working-odbc-connection-string-for-sqlite-in-aspsettings-json-for-net-core-razo/, the copyright belongs to the original page!
aspxhtmlmobile0898kendouidemosaspxhtml docs