1

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.)

1 Answer 1

2

Basic steps to use SQLlite in ASP.NET core 1.0 are as follows-

1) Create new ASP.NET core application

enter image description here

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

https://docs.efproject.net/en/latest/providers/sqlite/

Sign up to request clarification or add additional context in comments.

3 Comments

ok but what technology should i use in this context for web form like functionality to create a contact form and save the data ????
I am not sure whether I understand your question but as shown above we are using Entity Framework to create dbcontext and you can use same dbcontext to perform CURD operations. Refer any entity framework tutorial on how to read and write data.
what i meant was should i use as front end with reference to asp.net for a contact form

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.