Hi i have made a data sync project on top of entity framework.
the framework is schema independent to some extent.
i want to make it more tolerant to changes in schema even the currently considered breaking changes.
to achieve this i will have to get inside the ef migration engine and will have to generate a command like
add-transformation
which will be detecting the changes and creating a transformation.
I have looked into the source code of ef 6 but couldnt find an appropriate place to start.
any help would be appreciated.
Edit 1 :- answer to questions received in the comments
Extent:
Changes in data will be handled by the migration so no need to incorporate the changes.
What I need to is a way to execute a command like add-transformation
which would create a new transformation like a new migration. So typically lets say i have a database model (domain model) like
class A { public int a {get; set;} public int b {get; set;} }
then i change the class to the structure
class A
{
public int a {get; set;}
public int b {get; set;}
public int c {get; set;}
}
and then i run add-tranformation ClassChangesA
the code i require should
1. Detect changes
2. Generate a class like the migration class. Ex.
class Transformation_112334_ClassChangesA
{
public A Up(OldA model){
//Property C added
}
public OldA Down(A model){
//Property C removed
}
}
Open the Package Manager Console from Tools → Library Package Manager → Package Manager Console and then run the enable-migrations command (make sure that the default project is the project where your context class is).
I believe that the command you are looking for is add-migration migration_name then you can update your database using the command update-database, this is how to work with code first migrations in entity framework.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With