Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure an Entity Framework interceptor in an aspnet vnext config.json file?

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",
        }
    }
}
like image 296
Josh Pearce Avatar asked Feb 15 '15 12:02

Josh Pearce


1 Answers

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

like image 96
Slick86 Avatar answered Jan 02 '23 09:01

Slick86