vany0114 / EF.DbContextFactory

With EF.DbContextFactory you can resolve easily your DbContext dependencies in a safe way injecting a factory instead of an instance itself, enabling you to work in multi-thread contexts with Entity Framework or just work safest with DbContext following the Microsoft recommendations about the DbContext lifetime.
http://elvanydev.com/EF-DbContextFactory/
MIT License
93 stars 21 forks source link

Remove dependency on AspNetCore.All where it isn't needed #15

Closed ptyang closed 5 years ago

ptyang commented 5 years ago

It would be nice if AspNetCore.All could be removed from a dependency here, as it's quite large - and from looking at the extension/source file, there isn't a need there.

This would make using the EF.DbContextFactory nicer outside of the context of an ASP .NET Core application.

vany0114 commented 5 years ago

Hi @ptyang

You're right, you might want to use EF.DbContextFactory on a Generic Host or something like that.

BTW what is your use case? just curious...

So yeah, I'll let this issue open to work thru it in the near future, thanks!

ptyang commented 5 years ago

Actually I've just about wrapped up some changes in a repo where I've:

Both projects build and tests still run fine, I'm going to have a PR for you if you want to take a look for ideas on upgrading the rest of the projects

Also my use case is for a console application, so there's a use for EFCore, but no depedency on the AspNetCore stuff.

vany0114 commented 5 years ago

That sounds really good, go ahead with the PR!

TAGC commented 5 years ago

Yeah, I encountered an exception due to access by multiple threads to a shared DbContext and was looking into this project as a potential solution. However, I uninstalled when I saw it pull in the entire Microsoft.AspNetCore.All metapackage. For one thing that's a lot of dependencies but also it's pulling in the packages for ASP.NET Core 2 whereas I'm developing an ASP.NET Core 3 application.

So I'll hold off this library for now but probably take another look at it when this and #19 are merged.

vany0114 commented 5 years ago

Closing this issue since this was done on the V2.0 and it's available now.