locked
Increase seed time of my asp.net app RRS feed

  • Question

  • User-1204637165 posted

    Dear All,

    I have built a web application but right now I am having issues seeding all the data that I want to be present in my database from initial setup.

    When I run update-database in package console. Some of the data get seeded while others are left out. It does this without displaying any errors. The datas are quite much though. So I think I may need to increase the time or capacity that the sql server would use to seed my database.

    Please how do I do this.

    Thanks alot.

    Tuesday, July 16, 2019 5:37 AM

Answers

  • User753101303 posted

    Hi,

    You could try https://stackoverflow.com/questions/36977974/set-command-timeout-in-ef-6 but it is not supposed to fail silently (I would expect a timeout exception)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 16, 2019 6:22 AM
  • User1520731567 posted

    Hi InspiredJide,

    Example: set in the context constructor, so you don't need to set it once in every method that uses context.

    public TestDbContext() : base("name=MyTestDB") 
    {
    //Get the ObjectContext related to this DbContext var objectContext = (this as IObjectContextAdapter).ObjectContext; //Sets the command timeout for all the commands objectContext.CommandTimeout = xxx;
    }

    or 

    If you just want to set it in a separate method,for example:

    public List<model> GetModels()
    {
        using(var ctx = new TestDbContext())
        {
            ctx.Database.CommandTimeout = xxx; 
            ...
    } }

    Best Regards.

    Yuki Tao

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 16, 2019 9:47 AM

All replies

  • User753101303 posted

    Hi,

    You could try https://stackoverflow.com/questions/36977974/set-command-timeout-in-ef-6 but it is not supposed to fail silently (I would expect a timeout exception)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 16, 2019 6:22 AM
  • User-1204637165 posted

    Dear Pa,

    Thanks alot you the best. I would try this out now and get back to you.

    Best Regards,

    Jide

    Tuesday, July 16, 2019 6:45 AM
  • User1520731567 posted

    Hi InspiredJide,

    Example: set in the context constructor, so you don't need to set it once in every method that uses context.

    public TestDbContext() : base("name=MyTestDB") 
    {
    //Get the ObjectContext related to this DbContext var objectContext = (this as IObjectContextAdapter).ObjectContext; //Sets the command timeout for all the commands objectContext.CommandTimeout = xxx;
    }

    or 

    If you just want to set it in a separate method,for example:

    public List<model> GetModels()
    {
        using(var ctx = new TestDbContext())
        {
            ctx.Database.CommandTimeout = xxx; 
            ...
    } }

    Best Regards.

    Yuki Tao

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 16, 2019 9:47 AM