In this example demonstrate how to use the DotNetAge database as main DB.
#Challenges
- When you want to use the DotNetAge default database in module project you will get a migrations exception from EF.
- You want to use EF to access the tables that extended in DotNetAge default database.
#How to shared thd default database between DotNetAge and modules ? Following the steps below:
- Create your DbContext class and set same connection name in constructor default is "DNADB"
- Add your tables to the DotNetAge installed database by manual
- Open web.config of DotNetAge and find the "AutoMigration" setting in appSettings section and set to "False" (Requried DotNetAge 3.1.1)
- In your module registeration class override the OnAppStart method and set the data context Initializer to null.For example : Database.SetInitializer<TDbContext>(null);
#How to use this example
- Build the SharedContextTest project to DotNetAge/content/modules/[module-folder]
- Run the product.sql file in your SQL Server