Try our conversational search powered by Generative AI!

enableModelSyncCommit=false - DB is still updated (Commerce v 12.12)

Vote:
 

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

#250264
Mar 16, 2021 16:45
Vote:
 

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?

#250291
Mar 16, 2021 23:27
Vote:
 

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.

#250294
Edited, Mar 17, 2021 7:48
Vote:
 

If you are IgnoreMetaDataPlusSynchronizationAttribute to your property, it will not be synced to metafield. 

#250295
Mar 17, 2021 9:02
Vote:
 

Thanks, I didn't know about that attribute - seems to work!

But is there a bug in enableModelSyncCommit?

#250297
Mar 17, 2021 10:02
Vote:
 

It should work. I don't know why - that needs some more digging. Feel free to contact developer support service for further assistance :) 

#250299
Mar 17, 2021 10:49
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.