Extend Data Model: Modifications to Existing Custom Type

Posted by Community Admin on 04-Aug-2018 20:11

Extend Data Model: Modifications to Existing Custom Type

All Replies

Posted by Community Admin on 17-Nov-2016 00:00

I have followed the directions for extending the data model by setting up a custom type: docs.sitefinity.com/tutorial-extend-sitefinity-s-data-model

I was able to successfully setup my type... however, the documentation doesn't cover a few topics:

1. How to remove a prior attempt at type setup and re-run the  DB changes?
Based upon my research... drop the type's table and delete the provider from sf_schema_vrsns and sf_schema_vrsns_meta_types (not mentioned). Discovered this via: docs.sitefinity.com/thunder-develop-a-custom-module-using-an-openaccess-data-provider

2. How to flag the schema as requiring an update?
The documentation doesn't include this detail either. By decompiling the source... I found that Telerik.Sitefinity.Data.OA.OpenAccessConnection.MetadataUpgradeFacade's CheckForUpgrade method is reading the CurrentSchemaVersionNumber property.  By default... this looks at the Assembly Builder number of the project and by default that number is static. So changing your type and mappings is not triggering a schema update. To fix this... either have visual studio auto-increment the build number of the project or override CurrentSchemaVersionNumber in the provider and change it on every edit. To auto-increment the build number... open AssemblyInfo.cs and update the AssemblyVersion line to [assembly: AssemblyVersion("1.0.*")]. Details on this syntax at: msdn.microsoft.com/.../system.reflection.assemblyversionattribute(v=vs.110).aspx

Now the questions...

3. How do you modify existing properties/columns? Basically... how do you write code migrations in this context? Examples might be property/column renames, extending a column's length, or changing requiredness.

4. How do you delete an existing property/column?

5. How do you add a new property/column?

6. How do you migrate existing data during these changes?

7. Can you setup a series of migration/deployment steps?

Entity framework has migrations to accomplish this... but there's no mention in the Sitefinity documentation that I can find on a proper approach in the "Extend Data Model" context.

Thanks for the help!

This thread is closed