1
class DatabaseContext:DbContext
{
    public DatabaseContext(DbContextOptions<DatabaseContext> options):base(options)
    {

    }
}

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllersWithViews();
    services.AddDbContext<DatabaseContext>
}

I have tried uninstall then reinstall EntityFrameworkCore.But It didnt work.How can I fix it.Thank you in advance

2
  • 1
    Try to set the DatabaseContext class access modifier to public. By default it's internal. So if you are trying to access it from another project you will get this error. Commented Jan 4, 2023 at 19:26
  • You can read DbContext in dependency injection for ASP.NET Core to know more about DbContext in asp.net core. Commented Jan 5, 2023 at 6:34

1 Answer 1

2

Classes, records, and structs declared directly within a namespace (in other words, that aren't nested within other classes or structs) can be either public or internal. internal is the default if no access modifier is specified.

Class, record, and struct member accessibility

Internal types or members are accessible only within files in the same assembly they are defined: internal (C# Reference)

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.