Yesterday ASP.NET 5 RC1 was released. Yesterday was also a milestone for me as I switched over from my shared hosting provider for eggsbenedict.info to Amazon Web Services. This post details some of the obstacles I needed to traverse in porting eggsbenedict.info over from a full Windows-based ASP.NET 4.5 application to full Linux-based ASP.NET 5 application, and offers some open-source libraries that I have created to enable such a transition.
My current stack is as follows. All ASP.NET 5 components are beta8 as until today I was blocked by an issue from using rc1.
- Amazon EC2, Amazon Linux AMI
- nginx-proxy (for SSL)
- ASP.NET MVC 6
- Entity Framework 6 (patched for beta8 bug) and Npgsql
- ASP.NET Identity 3 with Entity Framework 6 mapping
I'm crazy excited by the fact this list doesn't contain Windows Server, IIS or SQL Server.
Entity Framework 6
The biggest obstacle was without a doubt replacing Entity Framework 7. EF7 is not mature enough as it currently stands, with many features existing in EF6 not initially planned for EF7. However, ASP.NET Identity 3 expects EF7, and EF6 migrations do not work in the new ASP.NET 5 project environment. To resolve these issues I created the following libraries;
Atquin.EntityFramework.Identity- ASP.NET Identity 3 mappings for EntityFramework 6
Atquin.EntityFramework.Migrations- Entity Framework 6 Migrations for ASP.NET 5
This was all working fine on ASP.NET beta7 until an issue in the rosylyn compiler hosed EF6 in beta8. Luckily @cherrydev saved the day with an EF6 fix for beta8. This package is not required if targeting beta7 or rc1.
Finally, I wanted a simple database exception logger that plugged into EF6 so I could stop using log4net.
Atquin.EntityFramework.Logging- ASP.NET 5 Logging provider for Entity Framework 6
As mentioned in an earlier post I had a version of eggsbenedict.info working against ASP.NET 5 beta7, however I couldn't get precompiled views to work which meant after every deploy, every single view on the site had to be recompiled by a request. Updating to beta8 allowed me to use this
Kestrel does not support HTTPS connections so far (although this may have made it to rc1), however there's a very cool docker-based nginx image that I've been using for virtual hosts, and now for SSL also. The setup was amazingly simple, run the container, copy the certificates, update the DNS settings and it just worked. This solution then breaks due to an rc1 issue but a work-around was confirmed about an hour ago.
Without a doubt the whole process of both deploying and environment debugging was made simpler thanks to docker. The ease at which containers can be brought up, thrown away, and brought back up again means deployments can be source-controlled scripts that point at any docker host.
Obviously rc1 is a go now, but eggsbenedict.info is currently stable on beta8 so I don't really need to update at this point. Naturally I'll use rc1 (or later) on any new projects I start using this epic docker-cloud-aspnet environment. Overall the experience of developing against a new, incomplete framework was as savage as it should be, but ultimately a rewarding and extremely geeky experience.