Database Configuration

In this video, we began configuring out database. We made our initial migration script so that our database could be created to store camp data.

These migration scripts are what allow your database to evolve over time. Maybe you find out you need to store more data in your model. This is possible by using the Add-Migration command and then applying the new migration with Update-Database command.

Our newly created database is local to our machine and will persist if you shutdown your application or machine.

After creating our database, we set up our Cross-Origin Resource Sharing (CORS) policy. Our CORS policy is what will allow our Angular frontend and ASP.NET Core backend communicate with one another. Our Angular app is from a different origin so we must specify that we allow this.

The policy we created is pretty wide open. In a production app, it may be a good idea to have a more restrictive policy.

Your Turn

Before moving onto the next video configure the database in your own application.

  1. Create your initial migration script for your database using the Add-Migration [script_name] command.
  2. Apply the migration script to you database with the Update-Database command.
  3. Setup your CORS so our Angular application will be able to communicate with our .NET Core backend.

I finished! On to the next chapter