Using TypeScript in ASP.NET 5

As we can read on the TypeScript it lets you write JavaScript the way you really want to. And guess what – you can do it in Visual Studio 2015! Visual Studio TypeScript support two different modes: File Scope: in this mode TypeScript files opened in Visual Studio Code are treated as independent units. As long as a file a.ts doesn't reference a file b.ts explicitly (either using…

By Dawid on (tags: asp.net 5, mvc, TypeScript, visual studio, vs, categories: code, web)

Multiple environments in ASP.NET 5

APS.NET 5 has introduced new environment variable called ASPNET_ENV. It allows us to control our application behaviour between multiple environments because it’s describing environment on which application is currently working on. We can put there whatever we want but typically it’s set to: Development Staging Production If we are working in Visual Studio 2015 then we can speci…

By Dawid on (tags: asp.net 5, environment, categories: code)

Why does the binding get updated only once in WPF user control?

Recently I struggled on my user control trying to make the dependency property be updated when I change the source of the binding. That confirmed my belief that WPF does not forgive any single developer’s mistake. For the sake of this post I simplified the code. The code of the user control was something like this And the xaml, here I use this control was like this Simple, noth…

By Mirek on (tags: dependency property, user control, WPF, categories: code)

Dependency injection everywhere

Just a few years ago there was just few people who known what dependency injection is. Today it is almost everywhere. Recently I’ve discovered that it can be also used in Razor views – thanks to ASP.NET 5. I will try to show you how we can use that feature on few examples bellow. Probably each of you have been populating drop downs in Razor views with data send from controller.…

By Dawid on (tags: ASP.NET, dependency, injection, IoC, next, razor, categories: code)

Converting Razor views into Pdf

This post talks about how you can convert Razor views into PDF. There is couple of NuGet packages which we can use to achieve that. I will try to describe couple of them. This library allows us to create documents in Portable Document Format (PDF). Some of the features: - generate documents and reports based on either provided HTML or by manually adding PDF elements such as tex…

By Dawid on (tags: convert, generate, pdf, razor, categories: tools, code)

Change Data Capture quick start

Change Data Capture is a feature of Sql Server (available since version 2008) which allows to capture all insert, update and delete operations on database tables. Here I am going to show you the simple way of enabling CDC on database, table and specific columns. The first thing to notice is that the Change Data Capture is available only on the Enterprise, Developer, and Evaluat…

By Mirek on (tags: audit log, Change Data Capture, categories: code)

How to access navigation property of deleted entity

In this post I am going to show you a small Entity Framework code first trick. When you remove an entity from the context its state is set to Deleted and all its navigation properties are nulled. This is done by DbContext internally. However you might want to know what was the related entities (navigation properties) before the entity was deleted. For instance you want to creat…

By Mirek on (tags: Code First, Entity Framework, navigation property, categories: code)

Concurrency handling in Entity Framework

In this post I am going to present my solution for handling optimistic concurrency scenarios in Entity Framework. This solution is somehow an extension of recommended approaches presented on MSDN Entity Framework learning  center here. Apart from pessimistic concurrency pattern, which assumes creating read or update locks on data when it is edited, this approach concerns o…

By Mirek on (tags: database concurrency, Entity Framework, categories: code)

Sql Server application roles with Entity Framework Code First Migrations

A time ago I have been writing about the Sql Server application roles, what are the benefits of using them and what are the limitations when we want to incorporate the Entity Framework to use application role. Today I will show you how to workaround those limitations with new Entity Framework facility introduced in version 6 of the framework. I am specifically talking about dat…

By Mirek on (tags: Application Role, Entity Framework, SQL Server, categories: architecture, code)

A confusing connection problem using Entity framework and Migrations

Recently I have stumbled upon a strange exception that raised in my application. It has led to an exception with a confusing message “Could not determine storage version; a valid storage connection or a version hint is required.” Thankfully I have solved this issue finally. I have check that it also occurs on the latest version of Entity Framework which currently is 6.1.2. To r…

By Mirek on (tags: EF, migrations, categories: code)