no suitable method found to override onmodelCreating .net core 3.0

asp.net-core c# entity-framework-core

Question

I have looked at a number of solutions but nothing helped so asking.

I am creating a very simple MvcApp in .Net Core 3.0 and it will be using EntityFramework 3.0 as well. This app is to learn .Net Core 3.0. I am using VS Code Editor Version: 1.40.1.

I have run the following commands (in order of appearance) to install EntityFramework:

>dotnet add package Microsoft.EntityFrameworkCore.Design
>dotnet add package Microsoft.EntityFrameworkCore.Tools
>dotnet add package Microsoft.EntityFrameworkCore.SqlServer 
>dotnet add package Microsoft.EntityFrameworkCore.Tools.DotNet 
>dotnet restore

The .csproj file looks like

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
  </ItemGroup>

</Project>

and the ApplicationDbContext look like

using Microsoft.EntityFrameworkCore;
using OneDishParty.Models;

//put the class inside a name space
namespace OneDishParty.Data
{
    //Extend from DbContext
    public class ApplicationDbContext : DbContext
    {
        //put the DbSet for the food items
        public DbSet<FoodItem> FoodItems { get; set; }
        //create constructor to load DbContext Options
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
        {
        }
        //create the onModelCreating and pass in the builder
        protected override void onModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);
        }

    }
}

onModelCreating is resulting in no suitable method found to override.

What am i missing here?

1
-1
11/17/2019 5:27:35 AM

Accepted Answer

Change onModelCreating to OnModelCreating. It's a capital O. Also, always remember the .Net naming conventions.

0
11/17/2019 6:43:53 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow