1

I have the following scenario:

I have a production database which is highly transactional. In order to keep queries efficient I would like to archive data from some of the tables to another database with exactly the same schema.

The relationships between tables are not very complex but any dependent objects would have to go with the archived data in order to uphold foreign key constraints.

Is there a simple way to do this using Entity Framework? I have tried to create two different contexts and add to one and delete from the other, but this is a bit of a tedious route.

If Entity Framework is not the best tool for this what is?

3
  • Under what conditions would you want to archive data? Data that's too old gets archived at some threshold? Data that gets deleted gets archived? etc. Commented Jul 30, 2013 at 21:54
  • You could build something in SSIS using a whole bunch of business logic, but the proper way to do this is (most likely) with partitioning. It has a host of pros and cons to weigh, however. Consult a DBA and maybe a BI developer. Commented Jul 30, 2013 at 22:21
  • @Ocelot20 I have some complex queries on the transactional data using EF. There are millions of rows and the queries are becoming slow. Even with proper indexing. I would like to archive data older than X months to a separate location to try speed things up. Commented Jul 31, 2013 at 7:45

1 Answer 1

1

There is no simple way in EF5 to do this.

If your database is MSSQL you can make use of partitioning for archive tables (see http://blogs.msdn.com/b/felixmar/archive/2011/02/14/partitioning-amp-archiving-tables-in-sql-server-part-1-the-basics.aspx for more information).

Sign up to request clarification or add additional context in comments.

1 Comment

I am not sure that EF queries are optimised to not look for data in other partitions. There is a cost for querying across partitions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.