Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michael 125 posts 409 karma points
    Feb 12, 2016 @ 07:32
    Michael
    0

    How to access to Umbraco database from console application

    Hi,

    Console app which access to umbraco db.

    For Umbraco 7.1.4 this works ok, but after upgrading to 7.3.7 I receive error: Current has not been initialized on Umbraco.Core.Logging.LoggerResolver. You must initialize Current before trying to read it. at Umbraco.Core.ObjectResolution.ResolverBase`1.get_Current()

    my db access was

     private UmbracoDatabase Db
            {
                get
                {
                    if (ApplicationContext.Current != null && ApplicationContext.Current.DatabaseContext != null)
                    {
                        return ApplicationContext.Current.DatabaseContext.Database;
                    }
    
                    return new UmbracoDatabase("umbracoDbDSN");
                }
            }
    

    How I can initialize Current?

    Thanks, Mike

  • Michael 125 posts 409 karma points
    Feb 12, 2016 @ 07:58
    Michael
    0

    After creating db with following code:

    var logger = Logger.CreateWithDefaultLog4NetConfiguration();
    new UmbracoDatabase("umbracoDbDSN", logger);
    

    I receive error when use PetaPoco:

    Db.TableExist

    Additional information: You must set the singleton 'Umbraco.Core.Persistence.SqlSyntax.SqlSyntaxContext' to use an sql syntax provider

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies