asp.net - Backup of the database in entity framework -


i working entity famework need transfer code

restore database [showing8-5-2013]  disk = n'c:\program files (x86)\microsoft sql server\mssql10_50.sqlexpress\mssql\backup\company.bak'  file = 1,  nounload,  replace,  stats = 10 

to code entity frame work

any thanks

ef db neutral provider concept. such commands nature db specific. ef exposes way execute sql command:

mycontext.database.executesqlcommand(); 

but may directly. pass sql command custom routine eg:

private static bool executesqlstatement(string connectionstring, string statement) {         int rowsaffected;         using (var sqlconnection = new sqlconnection(connectionstring)) {             using (var sqlcommand = new sqlcommand(statement, sqlconnection)) {                 try {                     sqlconnection.open();                     rowsaffected = sqlcommand.executenonquery();                 }                 catch (exception ex) {                     // handler or re-throw....                      return false;                 }             }         }          return rowsaffected == -1;         // see  http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executenonquery.aspx     } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -