📜  services.AddDbContext DataSource Sqlite - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:13.083000             🧑  作者: Mango

代码示例1
-- Using AspNet.3.1 EntityFrameworkCode w Sqlite database
-- Add Context class
public class DatabaseContext : DbContext
{
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSqlite("Filename=MyDatabase.db");
    }
}
 -- Add to Startup ConfigureServices
     services.AddEntityFrameworkSqlite ().AddDbContext ();