Entity Framework is Open Source Now!!!

Just in time when I have invested my time heavily on Asp.net MVC + Entity Framework, MS has announced that EF is now Open Source. This is huge. This will help me better understand the inner workings of EF and better design my applications.

As a reminder, Asp.net MVC is already Open source. Going through the code helped me understand how model binding work. 

Earlier I was nHibernate guy. Now I have totally switched to EF and this news further solidifies my leanings towards EF.

EF source code can be downloaded at http://entityframework.codeplex.com. It can be downloaded as a GIT repository. I was actually expecting a Zip file. But again, I can live with git based download too. 🙂

 

Advertisements

Aero Experience on Windows 2008 R2

I didnt know that we can install Aero Desktop experience on Windows 2008R2 server.

I was totally unhappy with the Windows 2008 R2’s classic windows desktop.  After following the steps  at http://windows.microsoft.com/en-US/windows7/What-is-the-Aero-desktop-experience

I was able to get Aero experience on my Windows 2k8 R2 machine.


Entity Framework Code First with SQL Server

As you know EF 4.1 Code First can create tables out of the model classes. If connection string is not provided in the config file, EF looks for local Sql express instance. If available, it connects to the instance and creates Database with table names same as your model classes.

But, what if you have a local SQL server instance instead of SQLExpress or your instance name is not SQLExpress? EF won’t connect automatically to the Instance in either of these cases,unless you explicitly provide your connection string.  How can you use the local SQL Instance without specifiying the connection string?

It is possible. Here is where we need to see what exactly EF looks for connecting to a SQL instance. To be precise EF looks for .\SQLExpress instance  in your local system. To make EF connect to any SQL instance just create an alias named “.\SQLExpress” for your SQL Instance. This can be done via SQL Server Configuration Manager tool as shown below.

Now EF connects to the SQL instance just fine as if it were local .\SQLExpress instance.


How to set Html.RadioButtonFor as selected by default in Asp.net MVC3

The below is the code snippet of how to use the Html helper for Radio Button in Asp.net MVC.

<td> Will Accept?</td>

 <td>

@Html.RadioButtonFor(x => x.WillAccept, true)

@Html.RadioButtonFor(x => x.WillAccept, false)

</td>

 

Now how can we show one radio button selected by default? There are two ways of doing it.

The first option is to pass the “checked” html attribute as a parameter to the Html helper method by creating an anonymous object as below

<td> Will Accept?</td>

<td>

@Html.RadioButtonFor(x => x.WillAccept, true, new { @checked = “checked” })

@Html.RadioButtonFor(x => x.WillAccept, false)

</td>

The Second option is to set the value of the corresponding model property in the controller itself

public ActionResult Feedback()

{

UserResponse usr= new UserResponse();

usr.WillAccept = false;

return View(“Feedback”,usr);

}

Both work perfectly, but note that, setting the value via model overrides passing via html parameter. So if both of the above options are used the default value of the radio button will be false.

Leave a reply if you find it useful


Cheap TFS hosting

Discount Asp.net offers limited time offer of 30days free TFS 2010 hosting and 20$/month. Looks reasonable offering. Details in the below link

http://www.discountasp.net/tfs/tfs-hosting-features-pricing.aspx


Asp.net vs LAMP – Case of Digg and StackOverflow Sites

ScottGu retweeted an interesting post today about Digg and StackOverflow

Nice RT @spolsky Digg: 200MM page views, 500 servers. Stack Overflow: 60MM page views, 5 servers. What am I missing?

then goes on to retweet the reason too

RT @spolsky (nb Stack Overflow is ASP.NET MVC + SQL Server, Digg was LAMP)

now that is very bold to claim isnt it..? Is PHP on Linux that bad in terms of performance..? I did some search and it seems the claim might be indeed valid at least as per the below link

http://www.computerworld.com/s/article/9017778/How_Digg.com_uses_the_LAMP_stack_to_scale_upward_

I will try to post some ASP.net MVC related stuff in coming weeks.


History of C# – Past present and future

Here is a nice summary of the past present and future of C# I captured from a  nice blog

  • C#1 was all about delivering a new language for a new platform.
  • C#2 was all about providing generics to improve strong typing, especially in collection handling situations.
  • C#3 was all about letting write strongly typed queries abstracted from the date source. As a consequence C#3 fosters a more declarative way of programming.
  • C#4 was mainly about dynamic programming to inter-operate with dynamic programming environment.
  • C#5 will be concerned with meta-programming.