3

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

Afshin
  • 1,405
  • 10
  • 18
  • 1
    Possible duplicate of [Toggling ProxyCreation in EF7 under new configuration](https://stackoverflow.com/questions/36222699/toggling-proxycreation-in-ef7-under-new-configuration) – Gabriel Luci Nov 25 '18 at 23:58
  • 2
    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 Nov 26 '18 at 00:04

1 Answers1

0

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
Alex Logvin
  • 766
  • 10
  • 12