1
votes

I'm developing a application using EF Core. I want disable proxy creation, but when I try to use the command an error appears.

My Db Context class:

public class BMContext : DbContext
{
     public BMContext()
     {
          this.Configuration.ProxyCreationEnabled = false;
     }
}

And the error:

Severity Code Description Project File Line Suppression State Error CS1061 'BMContext' does not contain a definition for 'Configuration' and no accessible extension method 'Configuration' accepting a first argument of type 'BeerMakersContext' could be found (are you missing a using directive or an assembly reference?)

Thanks :)

1
Proxy creation doesn't exist in EF Core by default. You have to install Microsoft.EntityFrameworkCore.Proxies to use it. So there is no real need to disable it (since you can just not install that package). - Gabriel Luci

1 Answers

0
votes

As suggested by Gabriel Luci:

You need to install Microsoft.EntityFrameworkCore.Proxies Package.

  1. In Visual studio go to ToolsNuGet Package ManagerManage NuGet Packages for Solution...
  2. In opened window go to Browse tab and search for Microsoft.EntityFrameworkCore.Proxies package.
  3. Click it and on the right choose the project you want to install it in (I suppose it's for server) and press Install