natemcmaster / DotNetCorePlugins

.NET Core library for dynamically loading code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I create automated migration for Plugin Tables ? [Question]

beslamirad opened this issue · comments

hi dear ,
first see this figure

migrations

i create a Simple Host Weblog with DataContext and 2 table
and want load plugin2 to host, (So far no problem)

Now , Ho To Add Plugins Table to Main DbContext ?
without add migration and ...
just Dynamic.

tanks

Hi,
Hope this helps adding models to existing dbcontext Also there is also this open source e-commerce project that uses similar method SimplCommerce which i am reading to figure out the principals behind sharing context b/w plugins and automagic migrations. also I am working on similar issues right now, so if you solve it first please share a sample repo on git.
And if i get to solve it first, I will share mine ;)

Happy coding

I can solve it, but mix Ef6 and Efcore

i lost you here :"but mix Ef6 and Efcore" if you meant that you are using both ef6 and core versions then no you cant mix these 2 dbcontexts as they are running on essentially different versions/techs.
as for this "How To Add Plugins Table to Main DbContext"
i solved it by extending main DbContext class to plugins and overriding their own configurations as needed.

In i solve all querys,insert, update , select and .... Execute via Efcore that use genericRespository ,but for add tables and add migration and update-database used Ef6 db context Automatic ,
*** both dbContext ModelBuilder send to plugin for add tables
*** Do you can Share Simple code from your sloved

Hi,
I have solved the issues and created a minimal sample.. I will upload it by tomorrow if I am free.. i will update my project repo link here.

here is the library example i created, it solves following issues:

  • multiple type of db providers (sql & mysql currently)
  • loading context models into core context from plugins
  • automatic migrations
  • apply/remove migrations on plugin install/uninstall
  • DataSeeding
  • can be enhanced for automatic migration generation too

https://github.com/aloksharma1/DBInjectionWithMultiProviders
the readme file is not updated yet as i have little time to work on other stuff these days, but here it is the code is clean and follow solid/clean architecture principals (i removed infra & service layers to reduce complexity).
hope this helps others too

This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please comment if you believe this should remain open, otherwise it will be closed in 14 days. Thank you for your contributions to this project.

Closing due to inactivity.
If you are looking at this issue in the future and think it should be reopened, please make a commented here and mention natemcmaster so he sees the notification.