Skip to content

Instantly share code, notes, and snippets.

@tdshipley
Last active April 25, 2016 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdshipley/2a5f80a4b375864578df to your computer and use it in GitHub Desktop.
Save tdshipley/2a5f80a4b375864578df to your computer and use it in GitHub Desktop.
Example of how to add EF 7 for SQLite to ASP.Net Core startup class
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddMvc();
// Add SQLite DB using EF Core
var path = PlatformServices.Default.Application.ApplicationBasePath;
var connection = $"Filename={Path.Combine(path, "mydb.db")}";
services.AddEntityFramework()
.AddSqlite()
.AddDbContext<MyDBContext>(
options =>
{ options.UseSqlite(connection); });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment