8

In a web config file, I would do this:

<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>

<interceptors>
  <interceptor type="System.Data.Entity.Infrastructure.Interception.DatabaseLogger, EntityFramework">
    <parameters>
      <parameter value="C:\tmp\DataAccessLogOutput.txt" />
    </parameters>
  </interceptor>
</interceptors>
</entityFramework>

But how do I do it in vnext's config.json:

{
    "Data": {
        "DefaultConnection": { 
            "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=aspnet5-Cupcake-a652ca1c-0d92-4155-ad46-bfb68bb538ee;Trusted_Connection=True;MultipleActiveResultSets=true"
        }
    },
    "EntityFramework": {
        "ApplicationDbContext": {
            "ConnectionStringKey": "Data:DefaultConnection:ConnectionString",
        }
    }
}
superjos
  • 12,189
  • 6
  • 89
  • 134
Josh Pearce
  • 3,399
  • 1
  • 23
  • 24
  • 3
    It is really unfortunate that most of this vnext stuff is so poorly documented. I keep finding questions like this just totally unanswered and really no documentation anywhere on the web. It's a let down. Because I truly think this json stuff can be better than web.config, but without the documentation it is utterly useless. – Robert Noack Apr 14 '15 at 03:30
  • @RobertNoack that's kind of the curse of beta software. – Carrie Kendall Apr 24 '15 at 18:21
  • @Josh: any luck in finding the answer? – BiLaL May 10 '15 at 07:32

1 Answers1

1

I actually think the functionality does not exist yet in EF7. It's on the backlog but does not seem to be implemented yet.

https://github.com/aspnet/EntityFramework/issues/1629

Chris Woolum
  • 2,854
  • 20
  • 20
  • Anyone aware of any updates to this? Because this question is very old and I have a specific use case in mind I asked a new question here: http://stackoverflow.com/questions/37660746/can-i-configure-an-interceptor-yet-in-entityframework-core – Warren P Jun 06 '16 at 15:05