0

I am trying to follow this tutorial on how to use .NET Core with SQLite3 and VSCode, but it is not made very clear what is meant by MvcMovieContext.

I understand that this is a db context from which calls to the database can be made, but how do I define this?

In my startup.cs I have

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();

    // Add the whole configuration object here
    services.AddSingleton<IConfiguration>(Configuration);

    services.AddDbContext<DBContext>(options => 
        options.UseSqlite("Data Source=LogonChecker.db"));
}

But of course I get

'The type or namespace name 'DBContext' could not be found (are you missing a using directive or an assembly reference?)

So my question is - what am I supposed to do with this? Just declare an empty DBContext class? All I want to do is create an extremely simple app which stores data in a sqlite database. Any help is much appreciated

2
  • What research into Entity Framework have you done? Commented Jan 9, 2018 at 5:16
  • DbContext (note the letter casing) is the base class for working with Entity Framework database mapping. The type argument in your config needs to be something defined in your project somewhere. If you want to use Sqlite, you're going to need to add the provider first. Probably want to start here: learn.microsoft.com/en-us/ef/core/providers/sqlite Commented Jan 9, 2018 at 5:47

1 Answer 1

1

The tutorial you are following assumes prior knowledge of Entity Framework--where the DbContext class comes from. I would follow this tutorial to get up and running with EF on .NET core.

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

Comments

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.