Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite scaffolding with Entity Framework Core

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.

like image 534
Dživo Jelić Avatar asked Jun 23 '16 07:06

Dživo Jelić


1 Answers

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
like image 156
Dživo Jelić Avatar answered Oct 12 '22 01:10

Dživo Jelić