Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alexinea/EntityFrameworkCore.LoggingExposure

Support to using EF6-like api in EntityFramework Core 2.x and 3.x
https://github.com/alexinea/EntityFrameworkCore.LoggingExposure

Last synced: about 1 month ago
JSON representation

Support to using EF6-like api in EntityFramework Core 2.x and 3.x

Awesome Lists containing this project

README

        

# EntityFrameworkCore.LoggingExposure
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Falexinea%2FEntityFrameworkCore.LoggingExposure.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Falexinea%2FEntityFrameworkCore.LoggingExposure?ref=badge_shield)

Support to using EF6-like api in EntityFrameworkCore, the api looks like `context.ConfigureLogging(...)`.

In EF6, we can use `context.Database.Log` to get or display SQL Text easily, but this api removed in EF7 (named EFCore today). We have to write much more code by using [Microsoft.Extensions.Logging](https://docs.microsoft.com/en-us/ef/core/miscellaneous/logging). This project solved it, and thanks you, [David Browne](https://blogs.msdn.microsoft.com/dbrowne/2017/09/22/simple-logging-for-ef-core/).

## Install

via nuget:
```
Install-Package Alexinea.EntityFrameworkCore.LoggingExposure
```

via dotnet cli:
```
dotnet add package Alexinea.EntityFrameworkCore.LoggingExposure
```

## Usage

```
using (var db = new BloggingContext())
{
db.ConfigureLogging( s => Console.WriteLine(s) );
//. . .
}
```

```
using (var db = new BloggingContext())
{
db.ConfigureLogging( s => Console.WriteLine(s) , (c,l) => l == LogLevel.Error || c == DbLoggerCategory.Query.Name);
//. . .
}
```

```
using (var db = new BloggingContext())
{
db.ConfigureLogging(s => Console.WriteLine(s), LoggingCategories.SQL);
//. . .
}
```

## Thanks

So much thanks to [David Browne](https://blogs.msdn.microsoft.com/dbrowne/2017/09/22/simple-logging-for-ef-core/), all the achievements of this project belong to him. I'm just a porter...emmm.... copied codes and publish it. 😋

## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Falexinea%2FEntityFrameworkCore.LoggingExposure.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Falexinea%2FEntityFrameworkCore.LoggingExposure?ref=badge_large)