Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/alexinea/EntityFrameworkCore.LoggingExposure
- Owner: alexinea
- License: mit
- Created: 2018-01-31T17:25:27.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-12-11T07:10:34.000Z (about 5 years ago)
- Last Synced: 2024-04-29T00:11:36.835Z (8 months ago)
- Language: C#
- Homepage:
- Size: 54.7 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)