In Migration we have two type of migration
- Automated Migration
- Code-based Migration
Below information’s are for Code-based Migration
Enable-Migrations: Enables the migration in your project by creating a Configuration class.
Add-Migration: Creates a new migration class as per specified name with the Up() and Down() methods.
The above command will create a “timestamp_MigrationName”.cs file with the Up() and Down() methods
Update-Database: Executes the last migration file created by the Add-Migration command and applies changes to the database schema.
Rollback Migration to previous one
PM> update-database -TargetMigration:"timestamp_MigrationName“
In .net core while register services with dependency injection container in “ConfigureServices(IServiceCollection services)” in Startup.cs, we can define the lifetime of the instance across the application using any one of the three methods.
- Only one instance will create and that instance will be available through out the application.
- So that when ever we need the instance that created during application start we could able to access it at any point in the application.
- At any number of http request we could able to access the same instance
- For each http request new instance will gets created.
- The instance gets created using AddScoped, will be alive only for that particular http request
- Irrespective of http request, every time when we look for an instance, it will create an instance every time
- Example, in an single http request if we are trying to access Student repository instance more than a time, each time it will create new instance separately