Delete database using OpenAccessContext

5 posts, 0 answers
  1. Caleb
    Caleb avatar
    3 posts
    Member since:
    Sep 2012

    Posted 22 Nov 2012 Link to this post

    Is it possible to delete  a database using the OpenAccessContext like it is in EntityFramework's DbContext?
  2. Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 27 Nov 2012 Link to this post

    Hi Caleb,

    Unfortunately dropping a database instance is not supported out of the box in the current OpenAccess ORM API. This is a design decision made mostly for safety reasons.
     
    You can still create your own extension method to drop a database:
    SqlConnection sqlConnection = new SqlConnection(@"Server=servername;Integrated security=SSPI;database=master");
     
    sqlConnection.Open();
     
    string databaseName = "DeleteTest";
    string sql = "DROP DATABASE " + databaseName;
                 
    SqlCommand cmd = new SqlCommand(sql, sqlConnection);
    cmd.ExecuteNonQuery();

    I hope this helps.

    All the best,
    Boris Georgiev
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
  3. DevCraft banner
  4. Caleb
    Caleb avatar
    3 posts
    Member since:
    Sep 2012

    Posted 27 Nov 2012 Link to this post

    Yeah, I already did that. But I was looking for a method that would work on all the supported databases. But it's fine. Are you planning to have support for that? Because migrating a database in the code only method bloats it with tables that are no longer in use and I have to delete it manually.
  5. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 30 Nov 2012 Link to this post

    Hi Caleb,

    What we have currently in our backlog is a functionality that would allow you to configure which old tables would you like to remove. For the time being we prefer not to allow dropping the actual database, again for security reasons. However, we might consider it (with the necessary precautions and limitations) in case there is demand for it after we provide the drop tables feature.

    Thank you for your input, we are looking forward to any additional feedback you might have for OpenAccess ORM.

    All the best,
    Ivailo
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
  6. Caleb
    Caleb avatar
    3 posts
    Member since:
    Sep 2012

    Posted 02 Dec 2012 Link to this post

    Okay, thank you for your assistance.
Back to Top
DevCraft banner