Code first models


#1

Hi, really loving what you guys are doing here, and planning on using your CMS!

We would like users to use predefined models across apps.

Is it possible by code, define and manage some standard models or we need to build some kind of schema synchronisation mechanisme using the CLI?

Also we plan that these models share some of the same attributes, is possible to make schema inherit from the same base model ( if it’s possible to do it by code )

Thanks.


#2

Thank you very much.

You have several options here:

  1. Use the sync feature for that.

  2. Write a custom command middleware that adds some (locked) fields to the schema whenever a schema is created. It could work similar to an app template: https://github.com/Squidex/squidex/blob/master/src/Squidex.Domain.Apps.Entities/Apps/Templates/CreateBlogCommandMiddleware.cs

But I have not tested it.

If you want to make deployments of new versions simple you can deploy this as a plugin, I created a sample here:


#3

Thank you so much for your quick reply :slight_smile:

I’ve looked at this: https://github.com/Squidex/squidex-samples/tree/master/csharp/Sample.Blog which i assume is one of the standard apps there is in Squidex you can choose. So i’m wondering if we have like 20 - 25 models, that we want all apps to use, and want to control it from a central point to update them would it be possible to build an app that contains all these models? and is the models schema automatically updated if the models are changed?

If not i think we will try to do a master app with all the models, and then a sync job that pull from the master and sync it into all the app, does that make sense?


#4

You have to go the path with the master app.