วันจันทร์ที่ 28 พฤศจิกายน พ.ศ. 2559

Entity Framework Migration Options

There are three important options, that you should know.

Friend NotInheritable Class Configuration
    Inherits DbMigrationsConfiguration(Of Models.MusicStoreDB)
 
    Public Sub New()
        AutomaticMigrationsEnabled = False
        AutomaticMigrationDataLossAllowed = False
        MigrationsDirectory = "MigrationFolder"
    End Sub

End Class
 
1. AutomaticMigrationEnable
When True, Entity Framework will automatically change the database structure to the latest version.
When False, You need to run Add-Migration and Update-Database yourself.

2. AutomaticMigrationDataLossAllowed
When True, Entity Framework will update the database schema according to the latest version of the model though some columns are removed, or datatypes are changed.
When False, Entity Framework will not update the database schema if any information is lost.

3. MigrationDirectory
This parameter is used to specified the MigrationDirectory. The default is "Migration" as it will create the folder called "Migration" in the project.

ไม่มีความคิดเห็น:

แสดงความคิดเห็น