Entity Framework Migration API

Hi, I made a data synchronization project on top of an entity structure. the structure is somewhat independent scheme. I want to make it more tolerant of changes in the circuit, even in the currently considered violations.

for this I will need to enter the ef migration mechanism and you will have to generate a command, for example,

add-transformation 

which will define change and create transformation.

I studied the source code for ef 6, but could not find a suitable place to run. Any help would be greatly appreciated.

Edit 1: - answer the questions received in the comments

  • First Code Approach
  • Volume:
    Changes to the data will be processed through migration, so there is no need to include the changes. I need a way to execute an add-transformation type command that will create a new transformation similar to the new migration. Therefore, you can usually say that I have a database model (domain model), for example

    class A {public int a {get; set;} public int b {get; set;} }

then I change the class to structure

 class A { public int a {get; set;} public int b {get; set;} public int c {get; set;} } 

and then I ran add-tranformation ClassChangesA
the code I require should


1. Change Detection
2. Create a class as a migration class. Example.

 class Transformation_112334_ClassChangesA { public A Up(OldA model){ //Property C added } public OldA Down(A model){ //Property C removed } } 
+5
source share
1 answer

I believe that the command you are looking for is add-migration migration_name, then you can update your database using the update-database command, here's how to work with the first code migrations in the entity infrastructure.

+1
source

Source: https://habr.com/ru/post/1265633/


All Articles