Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Windows C#4.0 Application , +
Hello
I work with entity framework. my db files in a directory.
I want get backup the database files. What software do move these two files?
This program is run when files are locked.
Is there any way other than copying files?
Posted 21-Aug-11 22:23pm
Comments
Keith Barrow at 22-Aug-11 3:26am
   
Is there any reason you can't just backup the database normally, without involving the entity framework?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If you are using MDBs then they will always be locked when in use. One way to do it would be to write a whackload of stored procs, wrap them with a 'backup' proc and call that from the client.
 
Consider using SQL 2008 Express, and host the DB there. That way you would be able to create backup maintenance plans, have other servers pull the data, etc. Lots of options. You can even use SQL Server Management Studio to do the backups by hand.
 
Cheers.
  Permalink  
v2
Comments
esmailian at 23-Aug-11 5:36am
   
my file extension is .mdf .but my db file not attach in SQL server . my connect to file and I need a trick to copy this file when my program run .
TheyCallMeMrJames at 23-Aug-11 11:00am
   
I'm sorry, esmailian, you're trying to do something that is designed not to happen here. Can you not figure a different approach? If the file is locked, it's locked. The OS won't let you carry the operation out. EF is not going to enable you to do this. You will likely need to write some really low level unmanaged code to do this.
 
Edit: read new answer below for one possible option. /eatingCrow
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I'm going to backtrack a bit...as it turns out you can use the shadow copy approach, but it may not fit your needs as you've described above. Certainly, it cannot be done with EF.
 
http://www.codeproject.com/KB/dotnet/makeshadowcopy.aspx?display=Print
Cheers.
  Permalink  
v2
Comments
esmailian at 23-Aug-11 15:22pm
   
Thank TheyCallMeMrJames but I cant work with vb . I work c#
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Database backup is a part of Maintenance not part of programming so go to Maintenance Plan feature of SQL server Management Studio.
 
How to: Create a Maintenance Plan, use :http://msdn.microsoft.com/en-us/library/ms189953(v=sql.105).aspx[^]
 
If you are using Express Editon (thus no SQL Server Agent is available for Maintenance Plan) see script given by ; http://ola.hallengren.com/[^] , Here free script is given.
  Permalink  
v3
Comments
CHill60 at 25-Jan-14 12:24pm
   
Good links but I really hope the OP hasn't waited over 2 years to take a backup

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 325
1 Sergey Alexandrovich Kryukov 289
2 CPallini 275
3 DamithSL 260
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 24 Jan 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100