Current filter:
                                You should refresh the page.
                                  • With the v16.2 release, the Security System provides the new navigation permission system in XAF applications. If your application uses Entity Framework as the ORM system and the Permission Policies security system, you need to perform a migration. It allows you to avoid the database version error and use the new functionality.
                                    After your application is updated using the DevExpress Project Converter, the following error can occur at the application startup:
                                    The model backing the 'MySolutionDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
                                    This occurs because the current database structure does not suit the updated application. To prevent this error, perform a migration with the following steps.
                                    1. Create the migration configuration
                                    Add a new class to the module project and specify its name. Replace the code in the new class with the code below.

                                    [C#]
                                    using System; using System.Data.Entity.Migrations; using MySolution.Module.BusinessObjects; //… public partial class MigrationConfiguration : DbMigrationsConfiguration<MySolutionDbContext> { public MigrationConfiguration() { AutomaticMigrationsEnabled = true; ContextKey = "MySolution.Module.BusinessObjects.MySolutionDbContext"; } }
                                    [VB.NET]
                                    Imports System Imports System.Data.Entity.Migrations Imports MySolution.Module.BusinessObjects ‘… Partial Public Class MigrationConfiguration Inherits DbMigrationsConfiguration(Of MySolutionDbContext) Public Sub New() AutomaticMigrationsEnabled = True ContextKey = "MySolution.Module.BusinessObjects.MySolutionDbContext" End Sub End Class

                                    In the code above, the MigrationConfiguration configuration was created for the context used in your project. Set the AutomaticMigrationsEnabled property to true to automatically apply the migration at the first application startup. The ContextKey property should specify a full path to your DbContext file in the current project.
                                    2. Set the initializer
                                    At the next step, the MigrateDatabaseToLatestVersion database initializer is registered.WinForms
                                    Open the Program.cs (Program.vb) file and add the following code there.

                                    [C#]
                                    using System.Data.Entity; using MySolution.Module; using MySolution.Module.BusinessObjects; static class Program { static void Main() { Database.SetInitializer(new MigrateDatabaseToLatestVersion<MySolutionDbContext, MigrationConfiguration>()); //... } //... }
                                    [VB.NET]
                                    Imports System.Data.Entity Imports MySolution.Module Imports MySolution.Module.BusinessObjects Public Class Program Public Shared Sub Main(ByVal arguments() As String) Database.SetInitializer(New MigrateDatabaseToLatestVersion(Of MySolutionDbContext, MigrationConfiguration)()) '... End Sub '... End Class

                                    ASP.NET
                                    Open the Global.asax.cs (Global.asax.vb) file and add the following code there.

                                    [C#]
                                    using System.Data.Entity; using MySolution.Module; using MySolution.Module.BusinessObjects; public class Global : System.Web.HttpApplication { protected void Application_Start(Object sender, EventArgs e) { Database.SetInitializer(new MigrateDatabaseToLatestVersion<MySolutionDbContext, MigrationConfiguration>()); //... } //... }
                                    [VB.NET]
                                    Imports System.Data.Entity Imports MySolution.Module Imports MySolution.Module.BusinessObjects Public Class [Global] Inherits System.Web.HttpApplication Protected Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) Database.SetInitializer(New MigrateDatabaseToLatestVersion(Of MySolutionDbContext, MigrationConfiguration)()) '... End Sub '... End Class

                                    After the initializer is set, the target database will be updated using the related migration configuration if the database state is not actual.
                                    To learn more, refer to the Code First Migrations MSDN topic.

                                0 Solutions

                                Creation Date Importance Sort by