Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to apply EF migrations only to local/in-memory data?

Here's the type of scenario I'm thinking of as well as what I think would be a solution, but I'm not sure if it can be done.

  1. Data is retrieved from a source that used a previous format of data; e.g. a file or disconnected database.
  2. The data is loaded into a local/in-memory context.
  3. Migrations are applied to the context, presumably still in memory.
  4. The data is now in the current format and is applied to the database.

The "previous format" could be different table structure, fields, data types, etc. essentially anything you'd expect a typical migration to be able to handle.

Is that possible?
Is that are reasonable solution?
If so, any pointers on implementation would be appreciated.

Thanks!


1 Answers

No. The crucial hurdle is in this part

Migrations are applied to the context

This is just not possible. Migrations are all about the store model. It compares a hash of the SSDL (Store schema definition language) of a context (edmx) to the hash that is stored in the database. If the hashes are different, the schema differences are analyzed and converted into change actions. Of course these actions are aimed at the store model.

like image 196
Gert Arnold Avatar answered Jan 05 '26 06:01

Gert Arnold



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!