VahidN / EFSecondLevelCache.Core

Entity Framework Core Second Level Caching Library
Apache License 2.0
326 stars 51 forks source link

Use EfSecondLevelCache.Core in apps other than asp.net core apps #31

Closed ysmoradi closed 5 years ago

ysmoradi commented 5 years ago

Summary of the issue

I tried to use this library with Microsoft.EntityFrameworkCore.SQLite 2.0 in Xamarin based mobile/desktop app. (A .NET Standard 2.0 based project). I stopped with the following exception:

Please add AddEFSecondLevelCache method to IServiceCollection and also add UseEFSecondLevelCache method to IApplicationBuilder.

Environment

The in-use version:
Operating system: UWP 17763 | Android 9 | iOS 12
IDE: VS 2017 15.9
Version: EFSecondLevelCache.Core 1.7.1

I think it's not possible to use this library in other scnarios too. For example, if I write a .NET Core 2 console app which gets executed by azure jobs, I'll receive the same exception, because there is no asp.net core there. I'm open to send a PR for this if you think it helps. Thnaks in advance.

VahidN commented 5 years ago

app.UseEFSecondLevelCache() is equal to the EFServiceProvider.ApplicationServices = serviceProvider;. More info from the unit tests project which its setup is the same as console apps. Also you can find a console app sample here.

ysmoradi commented 5 years ago

This approach is not possible anymore due recent breaking changes

VahidN commented 5 years ago

Yes. Just use services.AddEFSecondLevelCache();. That would be enough.

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.