Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code first EF migrations #2743

Closed
pepsinio opened this issue Apr 11, 2023 · 4 comments
Closed

Code first EF migrations #2743

pepsinio opened this issue Apr 11, 2023 · 4 comments

Comments

@pepsinio
Copy link
Contributor

Hi Shaun and community,
I have been playing around with Oqtane and overall am quite impressed and would like to do a lot more with it.

One thing which really bothers me and can't find a solution is how to enable EF code first migrations to be auto generated.
I plan to do lots of data modelling and doing it by hand doesn't really cut it.
I tried adding IDesignTimeDbContextFactory and other tricks, but because of the multitenancy can't really get it to work.
Is there an easy way to enable this? If it possible to use the 'default' database as baseline would do just fine.

Follow up question in case there isn't an option: Would you be open to accept PR enabling this?

Regards,
Peter

@sbwalker
Copy link
Member

Unfortunately, although multi-tenancy is a very common requirement for software applications, it is generally not a first-class scenario which Microsoft considers when developing its tooling or frameworks. In most cases it is possible to work around these limitations and create a multi-tenant solution, however it generally requires a fair amount of ingenuity (which is precisely why there is a need for value-added frameworks like Oqtane).

In regards to Oqtane and Migrations, there are actually multiple challenges. The first is multi-tenancy and second is support for multiple types of databases (ie. SQL Server, SQLite, PostgreSQL, mySQL). I have yet to see a solution which is able to support auto generated migrations while at the same time supporting multi-tenancy and multiple types of databases.

There is a fairly long thread which contains a lot of context of how Microsoft views the topic of automated migrations in .NET Core: dotnet/efcore#6214 .

@pepsinio
Copy link
Contributor Author

pepsinio commented Apr 12, 2023

Thanks for the reply Shaun!
Will follow up on this further. Will close the issue for now to not keep it hanging unless you would like to keep this topic open for others to contribute on.

Regards,
Peter

@sbwalker
Copy link
Member

@pepsinio One solution that others have used is to create a simple console project during development which is hardwired to your preferred database, and then use the standard CLI tool "dotnet ef migrate" to generate your migration code - and then manually migrate that code into your Oqtane module. It is still a manual process however it might reduce some of the manual effort.

@pepsinio
Copy link
Contributor Author

Thanks for the tip Shaun!
I did the same and seems to be the fastest route for plausible solution.
As you said not ideal by any extend but much better than doing it all manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants