You must set the singleton 'Umbraco.Core.Persistence.SqlSyntax.SyntaxConfig'

StackOverflow https://stackoverflow.com/questions/22095263

  •  18-10-2022
  •  | 
  •  

سؤال

I'm trying to use the Umbraco ContentService in an external MVC application.

In my controller:

var contentService = new ContentService();
var document = contentService.GetById(idofdocumenthere);

I put my umbraco connectionstring in the web.config file with providerName="System.Data.SqlClient.

This is the error I get after running this code:

You must set the singleton 'Umbraco.Core.Persistence.SqlSyntax.SyntaxConfig' 
to use an sql syntax provider

Parameter name: SqlSyntaxProvider

I also checked this link, but this didn't work.

Thanks in advance!

هل كانت مفيدة؟

المحلول

Don't instantiate a new ContextService, use the ApplicationContext.Current.Services.ContentService.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top