Posts

Migrating Legacy Apps to the New SimpleMembership Provider

Image
Asp.Net MVC4 uses the new SimpleMembership provider, changes the table structure and adds a new hashing algorithm. The reasons for the changes can be found in this article by Jon Galloway. This article shows how to migrate your existing apps to the new provider. I’m assuming that you stored your passwords in the unrecoverable SHA-1 format. If you didn’t, then you’ll have to change a couple of things. All of my apps are done this way so… I’m also assuming that you have created the basic skeleton of the new app and ran it once so the correct tables will be created. First, we’ll look at the new tables. Previously, we had all of those aspnet_xxxxxx tables. Here’s the new ones. UserProfile Contains all of the elements relevant to the user. This is a combination of the aspnet_Users table and the aspnet_Profiles table. webpages_Membership Stores the password info when not using OAuth, Live, Facebook, etc. This table is somewhat of a match to the aspnet_Membership table. webpage...

Windows 8 Keyboard Shortcuts

Image
There are numerous posts on the keyboard shortcuts in Windows 8. I’m not going to regurgitate those. Here are the common things you’ll want to do. Shut Your Computer Off, Network / Wi-Fi, Volume, Keyboard Press Windows+I which brings up the Settings bar (below left). Search, Change Application Settings, Manage Devices Windows+C which brings up the Charms bar (above right). Want to find a song or artist in Music, use The rest of the story If you want to read about other short-cuts and print a handy-dandy cheat sheet, visit the Windows Experience Blog . IE 10 Want to get the most out of IE10, then How-To Geek’s The Best Tips and Tricks for Getting the Most out of Internet Explorer 10 is exactly what you need. There’s also Internet Explorer 10 Shortcut Keys In Windows 8 which has some Windows 8 stuff also.

What A Week!!!!

I just returned from BUILD 2012 and I can’t say enough about it. If you’ve never been to a Build or PDC, you haven’t been to a conference. Microsoft pulls out all the stops!!! It is amazing. Of course, the goodies are great but they pale in comparison to the people you meet and what you learn. The People I met some amazing folks but my Hackathon team is at the top of the list: Glenn Henriksen , Geir-Tore Lindsve , Laura Thompson and Joseph Tu . Five folks who had never met came together win the Windows Azure category! These folks rock! I also met some ‘softies who just plain kick tail! Sreekanth Kannepalli was our mentor for the Hackathon and was invaluable in our win. We also got help from Denis Delimarschi. Of course, I can’t forget the Dan Fernandez, the host and moderator. It rocked, Dan!!! Arif Shafique and Theo Yaung are two other folks I met through the days. I’m telling you, Microsoft has some smart cookies!! The Goodies Each attendee got a Microsoft Surface RT 32GB, a N...

Diffference Between RegEx.IsMatch and the RegularExpressionAttribute

I was working on some code that stores a month as CCYYMM string. Of course I wanted to validate the string with Regex so I had the pattern ^20[0-2][0-9](0[1-9])|(1[0-2])$ Everything was fine as long as I was using Regex.IsMatch. The problems started when I used the RegularExpressionAttribute. Suddenly, I was getting errors everywhere. I constructed a little test to verify that there was a difference. What I found was that using the same string and pattern, yielded different results. Here’s my unit test. [TestMethod] public void DifferenceBetweenIsMatchAndRegExAttribute() { var pattern = "^20[0-2][0-9](0[1-9])|(1[0-2])$"; int cnt = 0; var months = new string[] { "201001", "201002", "201003", "201004", "201005", "201006", "201007", "201008", "201009", "201010", "201011", "201012" }; var attribute = new RegularExpress...

Updated Code To Get Class Definition From Table Structure

My previous post on Script to Create MetadataType classes was to work with LINQ-To-SQL and partial classes. EF 4.1 introduces Code First which uses POCOs and here is the code to create a class definition from a table’s structure. Enjoy. SET NOCOUNT ON declare @TableName varchar(256) = 'BusinessTypes' declare @EntityName varchar(256) = 'BusinessType' declare @TableSchema varchar(256) = 'dbo' declare @ColumnName varchar(256) , @DataType varchar(256) , @NewDataType varchar(256) , @MaxLength int , @Nullable varchar(5) declare @Lines table (Line varchar(1000)) insert into @Lines select 'public class ' + @EntityName insert into @Lines select '{' declare @DataTypes table (SqlDataType varchar(1000), DataType varchar(1000)) insert into @DataTypes (SqlDataType, DataType) values ('bit', 'bool') insert into @DataTypes (SqlDataType, DataType) values ('char', 'string') insert into @DataTypes (SqlDat...

Replacement for ExpectedException in MS Test

This StackOverflow thread has a great solution for the issue that ExpectedException does not allow you to validate the error message. Look at the response from winSharp93 and the ExceptionAssert class. This is a much cleaner method and also shows some great ways to use generics.

Script To Grab Column Names As UML Properties

I was cooking up some UML diagrams for an existing DB and wanted to get all of the properties. It lists the table, column name in UML markup format and then the data type. The data type column is there so that all I have to do is order it by the second column and I’ll get all of the nulls so I can see if I’m getting a data type that I haven’t handled. The data type conversion is by no means complete but it’s a good start. Enjoy! select table_name, '+ ' + column_name + ' : ' + CASE WHEN DATA_TYPE in ('ntext', 'nvarchar', 'varchar', 'char') then 'string' WHEN DATA_TYPE = 'bit' then 'bool' WHEN DATA_TYPE = 'int' then 'int' WHEN DATA_TYPE = 'timestamp' then 'timestamp' WHEN DATA_TYPE = 'uniqueidentifier' then 'Guid' WHEN DATA_TYPE = 'money' then 'decimal' WHEN DATA_TYPE in ('smalldatetime', 'd...