This is a migrated thread and some comments may be shown as answers.

Delete database using OpenAccessContext

4 Answers 84 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Caleb
Top achievements
Rank 1
Caleb asked on 22 Nov 2012, 08:07 PM
Is it possible to delete  a database using the OpenAccessContext like it is in EntityFramework's DbContext?

4 Answers, 1 is accepted

Sort by
0
Boris Georgiev
Telerik team
answered on 27 Nov 2012, 03:58 PM
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.
0
Caleb
Top achievements
Rank 1
answered on 28 Nov 2012, 03:25 AM
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.
0
Ivailo
Telerik team
answered on 30 Nov 2012, 02:21 PM
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.
0
Caleb
Top achievements
Rank 1
answered on 03 Dec 2012, 05:05 AM
Okay, thank you for your assistance.
Tags
Data Access Free Edition
Asked by
Caleb
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
Caleb
Top achievements
Rank 1
Ivailo
Telerik team
Share this question
or