ReBuildAll Blog
Thoughts (mostly) on .NET development

Moving ASP.NET Identity model into another assembly   (ASP.NET)   
Visual Studio 2013 and MVC 5 has arrived (as well as the "One ASP.NET"), with ASP.NET Identity in tow. The new identity feature allows user profile information to be part of the ASP.NET Identity model. In essence, the identity data structure can be merged with whatever data your application has, creating a seamless integration of identity data and application data.

The result? You do not need to have two data models / entity models for your application (and as such, two Entity Framework DbContext's).

Microsoft also provides a description of how this can be achieved, using Entity Framework migrations.

But what if you want your data model to live in another assembly, not the default web application? Reasons for such a thing might be a shared data access layer between different applications. You could have a Web application and another service that does background processing, both of which need access to your data.

The default ASP.NET MVC 5 project will have an IdentityModel.cs file in the Models folder. This contains the expandable identity model. But it is included in your Web application.

This is a description of how you move the identity model to another DLL.

Add a class library
The first step in moving your data access logic to a central assembly is adding a new class library project to your solution. This new class library will contain the data access layer, and you will reference it from other projects that need data access.

Go into NuGet package management, and add the Microsoft ASP.NET Identity EntityFramework package to the project. This will also pull in some dependencies.

Now you are all setup to actually move the identity model here.

Move over the identity model
Next, take your Models/IdentityModel.cs file from the Web application and move it into the new class library. (Move, and do not copy it. It should not be in the Web application after this step).

Change the namespace in the file to match that of your intended data access layer.

Optionally, you might want to create a separate file for the data context class. This would be a good time to do that.

Add references and usings
Last step, go back to your Web project and add a reference for the data access library.

Open AccountController to add a new using statement for your new data access namespace.

Start working on the data access layer
And now you are done. You can now add your entity classes and add IDbSet properties to the data context class. Build your data access layer. You will have only one data context class, that has both your application data and your identity data together.

WoDalmanac   (Apps)   
So I had this idea that I will start publishing some of my so far private work as open source. I do not know how much time I will have supporting this idea, but it seems like something good to do. I decided to start a new blog dedicated to this effort (which does not mean I want to abandon this one).

As a first application I published WoDalmanac. It is a tool I did for our role playing game sessions. Very useful for Vampires and Werewolves :-)

Read more about this tool here: WoDalmanac

From there you can visit the Bitbucket repository or download in binary format. It is written in C# and runs as a Windows application.