| Subcribe via RSS

Windows 8 Consumer Preview:For Desktop

March 5th, 2012 | No Comments | Posted in General

I gave Windows 8 a go by booting from VHD.

I specifically wanted to test drive Visual Studio 2011, because of so many changes. I will come to it at a later date.

First things first, I was met with big Windows 8 surprise. I couldn’t actually get hold of it like a regular desktop, have to keep going it back and forth with “Desktop” mode and “Metro” mode.

From a veteran PC user’s perspective, I must say, I was extremely disappointed!. Specially Metro sucked for following 2 tasks :

  1. Switch between applications
  2. Have multiple windows open side by side

While I do agree they won’t be giving any “default” Desktop mode in Windows 8 (not without a hack anyways), I think they must stick back our beloved taskbar back.I think it should be stationary like right now and should list all apps including Metro apps. It includes system tray as well. This can be made as a setting as well. This way Metro becomes a launcher on steroids (better than Win 7 + Fences).

This is how I think it should look :

proposed windows 8 with taskbar for desktop users

proposed windows 8 with taskbar for desktop users

Please share your views :)

EF v4.1 Code First and ASP.NET Membership Service

April 4th, 2011 | 2 Comments | Posted in ASP.NET MVC, Entity Framework

Entity Framework 4.1 Code First has really simplified the start for an application. You can virtually start File>New Project>New Class and start creating your Model.

 

For those that are unaware, EF Code First has a “Initializer” mechanism where you have to set if you wish to drop the database to re-recreate based on your Model and Relationship, as well as DbModelBuilder conventions that you may have set on your DataContext Class.

 

But once Model is created, you most definitely want to quickly scaffold the application that you wish to create. This most definitely will involve ASP.NET Membership classes interaction. But since EF Code First Drops the database every time the model changes, you have to run aspnet_regsql  each time the database is dropped. This is a big annoyance once you get hold of it.

EF Team is working on something like an evolution of this approach, but when that is available is a good guess.

THE WORKAROUND!

If you are using SQL Server with your ASP.NET MVC Application, you are in luck!. Back since SQL Server 6.5(may be before that, I don’t know!), they used to ship something called a “Model” database. Whenever someone creates a new database in SQL Server, all the properties and tables of the “Model” database is inherited in the new database!.

 

So effectively you can run aspnet_regsql against your “Model” database in your development system and then each time Entity Framework creates a new database, it will inherit aspnet Application Service tables!

 

Now all that is  remaining to do is to create sample users and roles. You can do this easily by inheriting a new class as :

public class MyDatabaseInitializer : DropCreateDatabaseIfModelChanges<YouDataContextClass>    {        protected override void Seed(YourDataContext context)        {            base.Seed(context);            //Add a User and Role Sample!            Membership.CreateUser("parag", "test123");            Roles.CreateRole("Admin");            Roles.AddUsersToRole(new[] {"parag"}, "Admin");        }    }

 

And you need to add this to your Global.asax in “Application_Start” :

Database.SetInitializer<YourDataContextClass>(new MyDatabaseInitializer());

Let me know if this helps!

EDIT : You need to enable “Role Manager” in web.config for roles to work.

Tags: , , ,

Resumption to Blogging – A new Begining!

March 1st, 2011 | 2 Comments | Posted in General

So Finally I decided to re-up the site and will be blogging again.

With this blog I plan to share knowledge as well as learn new stuffs. This Blog is going to be about anything and everything related to .NET, India, Politics, and other stuffs!

Thanks for reading thus far…