C#

C# trigger after database changes with SQLDependency

I found the following amazing article with some code that works without any modifications. With SQLDependency, you can listen to database changes with a predefined query.  If something happens to this result set (INSERT/DELETE/UPDATE) an event will be triggered, allowing you to take action.

Continue reading

Advertisements
C#, MEF

Tutorial on creating loosely coupled applications with MEF

When I first read about MEF (Managed Extensibility Framework), I thought it was a great concept to create plugin-based applications, allowing customers to customize some behavior of the application for instance. Putting the whole concept into reality is something different, so in this article I will give a brief overview of the steps to take to get started with MEF.

Continue reading

C#, Cloud, Entity Framework, MVC

Creating SQL schemas using Entity Framework Code First

As you might have read in my previous post, I used SQL schemas to partition data between tenants. Being part of the true definition of SaaS, a new tenant should be up and running within minutes without any human intervention.

With my suggested approach, we need to do two things:

  • Registering a new tenant
  • Attaching users to the tenant

In this article, I am going to focus on the first item whereas the second one shouldn’t be a big deal if you are planning to create software as a service.

Continue reading

Cloud, MVC

Multi-tenancy with ASP.NET MVC and Entity Framework

Until recently I have never had the time to concentrate on cloud application development. All of the projects (non-SharePoint related) I have ever worked on were dedicated to only one customer, so the multi tenancy challenge never came up. Although my own website is hosted on Azure, I realized I had to create my own project to gain some knowledge on this area.

There are many books and web pages available regarding cloud development, but for a very good reason none of those give really specific examples: it all depends on what you want to achieve. In this article, I will cover one scenario that is quickly to implement with the knowledge many .NET developers probably still have, which is developing a ASP.NET MVC application with Entity Framework which ensures storage in one database with multiple schemas. By giving some code excerpts, I hope to give you some rough ideas how to make your own multi-tenant applications.

Continue reading