SQLite scaffolding with Entity Framework Core

c# entity-framework-core sqlite

Question

When I run

Scaffold-DbContext "Filename=mydatabase.sqlite3" Microsoft.EntityFrameworkCore.Sqlite

I get an empty context

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace MyNamespace
{
    public partial class mydatabaseContext : DbContext
    {
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlite(@"Filename=mydatabse.sqlite3");
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
        }
    }
}

Am I doing something wrong. Is this available for SQLite?

I have a single table in the database with id and name, just a simple example to get me going.

1
5
11/3/2016 2:27:42 PM

Popular Answer

It is creating a new database in bin folder because of the relative path in the connection string. I used new connection string.

Scaffold-DbContext "DataSource=C:\dev\mydatabase.sqlite3" Microsoft.EntityFrameworkCore.Sqlite
4
6/23/2016 8:06:11 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow