Proper way to work with EF Core #4713
-
Hello, Can you please comment if the following steps are the correct way to develop a new custom Oqtane module that works with EF Core:
This is the step that bothers me. I am used to work with EF Core using the dotnet-ef tool to generate all the boilerplate database code from the models. If I switch to application development with Oqtane, should I implement the database maintenance code from the models by myself, or there is more automated way? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Try out https://amazingoqtanestudio.com It will generate all the code for you |
Beta Was this translation helpful? Give feedback.
-
@neterror Oqtane is multi-tenant and the standard EF Core command line tool does not support multi-tenancy - so it is not possible to use the traditional workflow you described. The general approach is to create an entity builder for each entity (model) and then create migrations for each version of your module where entities change. Use the standard version number convention to ensure migrations are executed in order. And the most critical thing to remember is to update the version number in the ModuleInfo.cs manifest file to match the latest migration version, as this is how Oqtane knows that a module requires upgrade logic to be executed. Migrations are not difficult to create manually using a code-first approach. They can be a bit tedious but it's usually helpful to understand what is happening under the covers. If you want to use the command line tools, you should be able to create a separate database, add an appsettings.json in your module server project, modify your model classes and then have the command line tool generate the migration classes - which you can integrate into your Oqtane migration classes. |
Beta Was this translation helpful? Give feedback.
Try out https://amazingoqtanestudio.com
It will generate all the code for you