Why would you want to not sync the model? Does it make sense to just add the attribute to property so it is not mapped to to metafield?
Which attribute do you mean?
Here is some more background: We have a large content model in our db (of meta classes and meta fields). It was set up manually long ago and is not synchronized from code (because there is no code). Now we need to support insertions of new content items via an API and IContentRepository seems like our best candidate, for example like this:
var newProduct = _contentRepository.GetDefault<MyProductContent>(categoryReference);
newProduct.Created = DateTime.Now;
newProduct.MetaField1 = "asdasd";
_contentRepository.Save(newProduct, AccessLevel.NoAccess);
[CatalogContentType(GUID = "2A2CD711-0D35-48E5-8687-26B92CE1A2E8", MetaClassName = "Product_MyProduct")]
public class MyProductContent : ProductContent
{
public virtual string NewMetaField1 { get; set; } // This automatically gets added to the db during startup
}
As for me personally I'd much prefer having the whole model defined in C# code rather than in database tables. However, time is a factor here and so is the fact that we have a production database that we don't want changed at this stage. Reverse-engineering the content model from db seems like an error-prone and tedious process, which is why the option enableModelSyncCommit fit our needs.
If you are IgnoreMetaDataPlusSynchronizationAttribute to your property, it will not be synced to metafield.
Thanks, I didn't know about that attribute - seems to work!
But is there a bug in enableModelSyncCommit?
Hi,
New meta fields that I add to a content type (in this case a class inheriting from EPiServer.Commerce.Catalog.ContentTypes.ProductContent) are inserted into the database on startup, even though I have set enableModelSyncCommit to false in web.config. I have verified the runtime value of Settings.Instance.EnableModelSyncCommit to be false in one of our initialization modules. Any ideas why this is happening? Are there any other ways to disable the committing of model synchronization changes?
Best regards,
Hampus