Posted with : Entity Framework, Cloud Platforms

EntityFramework - deploy custom stored procedures to Azure

Continuing on my previous post regarding EF-Azure for project IOnline, I need to adapt this requirement to: (1) Not using EF to count number of messages (total messages in the system and by categories) and (2) Use Dapper for the data access layer as a replacement. So I will have to create some stored procedures to make this works.

1. Create stored procedures and references to Dapper

Below is the SP needs to be created

_config.yml

The application will function after implemented a new service using Dapper.

_config.yml

2. Enable migration

If the system runs on another database or Azure platform it doesn’t work unless the script was deployed manually. Again, it should be deployed automatically with continuous integration enabled. So a new migration is needed.

_config.yml

The above migration was empty when running Add-Migration command because no change has been made on the model. To integrate the SP, new properties UpScripts and DownScripts are created which contains sql statements to perform the migration.

And that’s all from our side, the rest is EF it will perform Update-Database on the first read/write db operation. We can take a coffee and see new affects after push those changes, Azure handles all other steps.

References

  1. Code First Migrations and Stored Procedures
Written on August 30, 2015

Tags