I am using Entity Framework, C# 4.0 and Visual Studio 2010. I need to execure a simple SQL query to delete the content of four tables. The query contains:
DELETE FROM dbo.tblMFile
DELETE FROM dbo.tblMContacts
DELETE FROM dbo.tblPersonDetails
DELETE FROM dbo.tblAddresses
There is a foreign key contraint between some of the tables.
There seems to be no simple way to do this.
With reference to my comments on the first respondant’s answer:
-
Because of the highly confidential nature of the data I NEED a way to quickly delete all content (a requirement and a security issues)
-
I am new to EF and keen to learn
-
I am using delete instead of truncate because of the foreign key constraints mentioned above (also the SQL above is illustrative, not definitive).
-
I am a firm and long time believer in strong typing and prefixes all my objects with a type indicator. It has saved me hours (or days even) of debugging.
-
Humans are polite, sensitive and informative (among many other attributes). I aspire to be human.
To add to the answer from @TomTom. You can’t do that directly using Entity Framework. But you can:
ExecuteStoreQuerysee see and write the SQL command directly