Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to create console application to setup as scheduled task to perform database operations #8912


User avatar
0
ISTeam created

We have ASP.NET Core MVC and jQuery 8.3 version template. We need to get data from four different CMS systems siting in different DMZs than deployment location of the MVC web applicaiton. So, we cannot use background workers - hosted service to import data directly on deployment server.

For that reason we need to create four console application clients, which will dump data after reading from each CMS system databases. Frequency to import data is also different for all systems, so we can easily configure by creating scheduled job in Windows Task Scheduler. I need to perform only basic CRUD operations on few EFCore entities and reflect in Dashboard database for the import task.

Please advice if there is any sample or documentation on how to create console application to perform such activity using such an independent agent.


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    You can use the abp framework in the console application(including ef core).

    Please check the related sample. https://github.com/aspnetzero/aspnet-zero-samples https://github.com/aspnetboilerplate/aspnetboilerplate-samples

  • User Avatar
    0
    ISTeam created

    Even after two years, surprisingly same thing happened like comment by @outdoored on thread 5403 https://support.aspnetzero.com/QA/Questions/5403

    I was spending more than two days to resolve the problem of ObjectDisposedException to access repository in my own separate console applicaiton to be used as a task scheduler job independently just to import data.

    To make life simple, I first used the exact same code of 'X.Migrator' application and just added my code in the 'MultiTenantMigrateExecuter.Run()' method to access some other reposiotry of the same database. But unfortunately I was getting same error. Even [UnitOfWork] did not work for me.

    And as last hope, I restarted my machine and suddenly after restart it is working with [UnitOfWork]! with Tenant repository onlu which is defined by Abp. But not for any other entities created by us.

  • User Avatar
    0
    ISTeam created

    Fixed it by adding virtual keyword in the method!