I actually searching for a simple asp.net core (1.0) web application sample using sql lite as back end.
Can someone point me in the right direction
Basically I need to just create a contact me form in asp.net core and have a sql lite as back end.
Thanks in Advance for the replies.
(PS: asp.net core sample, one that will actually work in vs 2015 and will not give... The dependency does not support framework .NETCoreApp,Version=v1.0.)
Basic steps to use SQLlite in ASP.NET core 1.0 are as follows-
1) Create new ASP.NET core application
2) In project.json, add these packages-
"Microsoft.EntityFrameworkCore": "1.0.1",
"Microsoft.EntityFrameworkCore.SQlite": "1.0.1"
3) Create DatabaseContext.cs in your project-
using Microsoft.EntityFrameworkCore;
namespace AspNetCore_SQLlite
{
public class DatabaseContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Filename:myTestDB.db");
}
}
4) In ConfigureServices method of startup.cs, add DbContext service-
services.AddEntityFrameworkSqlite().AddDbContext<DatabaseContext>();
5) In Startup method of startup.cs, create DB like this-
using (var db = new DatabaseContext())
{
db.Database.EnsureCreated();
}
For more information, you can refer these articles-
https://docs.efproject.net/en/latest/platforms/netcore/new-db-sqlite.html