Mike Borozdin's Blog

A blog about programming, web and IT in general

Send Your Feedback about Internet Explorer 8 and Other Beta Products

I must admit perhaps I was too rude when I was describing the glitches with IE8 Beta 2 usability. First of all, it was beta which purpose was to demonstrate new features and gather feedback, but no to present a completely finished product. Second, it were my own thoughts, but still IE remains the most popular browser on the Net and people must find it useable, since they use it.

Anyway, Internet Explorer 8 Release Candidate 1 is available now, which means that there won’t be any new functionality in the release, however if they find any bugs in the current RC, they will fix them and make RC2 available for public.

So, if you want to submit any bug report of feature request, I strongly advice you take part in the Microsoft Connect program that allows you to send feedback about their beta products, including Windows Azure, Windows 7, IE8 and many other products. Just navigate your browser to connect.microsoft.com, sign-in with your Live ID and choose an appropriate program. It’s advisable to search through the database before submitting your bug report or a suggestions, because it’s likely that other people have already spotted that bug and complained about it or came up with the same feature request.

Participating in such programs and sending feedbacks allows Microsoft to make better products that you will like ;-)!


Tags:
Posted by Mike Borozdin on Friday, January 30, 2009 1:09 AM GMT
Shout it Kick it!  
Permalink | Comments (3) | Post RSSRSS comment feed

Free Entity Framework Learning Guide

I came across a wonderful learning guide for the Entity Framework that explains many essential and complex things about the Entity Framework, including:

  • Modeling Entities
  • Lazy Loading
  • Inheritance
  • Working with objects
  • Performance
  • Working with Stored Procedures

Moreover this 500 pages long learning guide is absolutely free and can be downloaded here with all examples.

http://weblogs.asp.net/zeeshanhirani/archive/2008/12/18/my-christmas-present-to-the-entity-framework-community.aspx


Posted by Mike Borozdin on Monday, January 19, 2009 2:02 AM GMT
Shout it Kick it!  
Permalink | Comments (2) | Post RSSRSS comment feed

Thoughts on Internet Explorer 8 Usability

Well, Internet Explorer 8 is in the beta phase only, so it may be to early to judge it and make any conclusion. Anyway, I have some thoughts I want to share.

I’ve been a long time Firefox user, even though I cannot say anything bad about IE, unlike some other people who always tend to whine about it, I was just used to Firefox, anyway, I decided to try IE 8 Beta 1 and now I’m using Beta 2. It looked very promising to me. It passed the Acid2 Test, it has the Developers Tools and a built-in JavaScript debugger. So, Microsoft intends to release a more developer oriented browser that may surprise many web developers who have a bad opinion about Microsoft as a company that produced a very crappy browser and simply don’t care much about web standards and web at all. It’s not right, of course.

Anyway, this time I’m going to talk about features that are oriented not only for developers but for everybody. And Internet Explorer 8 has something to offer, starting from Web Slices, Accelerators that allow you to get content without loading a new page, for instance, you can easily look up a word in a dictionary or find a place on the map

3

and InPrivate browsing. But I as a Firefox user was surprised that IE lacked some essential features, at least I got used to them when using Firefox. For example, I cannot simply copy an e-mail address, in Firefox I would right-click on the e-mail and choose “Copy Email Address”, in IE8 I can only copy the full address beginning with “mailto:”. Then, I cannot just copy the URL of a picture,

 1

instead I have to go to “Properties”, select its address and then copy.

2        image

 

Brrr… That’s nasty. I believe there are some other things that drive me crazy, but at the moment I can’t remember them.

Yep, I have just remembered yet another glitch, middle-click that should open a page in a new tab doesn’t work when I open page from the favourites menu…

Moreover, there are the developer tools, a JavaScript debugger, a good source viewer, but there’s no shortcut for source viewing, in Firefox I would simply press CTRL+U, in IE I’m constantly hitting the same combination and realize that I have to right-click and choose “View source”.

Well, these things are just minors glitches, but I think these minor things are very important. If one is used to the same set of convenient features in one browser, then it’s a good idea to implement them in another. I hope, the final version of Internet Explorer 8 will have great usability and it will a really great browser that everyone will enjoy :-)!


Tags:
Posted by Mike Borozdin on Saturday, January 17, 2009 4:08 PM GMT
Shout it Kick it!  
Permalink | Comments (4) | Post RSSRSS comment feed

Understanding Attaching/Detaching Objects in LINQ to SQL and in the Entity Framework

LINQ to SQL and the Entity Framework are very powerful tools, however as in many other useful tools there are some things you should be aware of when working with them. One of those things is object attaching and detaching. Let’s have a concrete example.

As you already know, you can retrieve an object from the database, update or remove it and all the necessary changes will be submitted to the database.

But what if you don’t want to perform additional SELECT query? Instead, you want just to perform one necessary query, either to update an object or remove it

Well, a quite logical idea is to create an object, set an appropriate ID attribute and then update/delete it:

NorthwindDataContext db = new NorthwindDataContext();
 
Product product = new Product { ProductID = 1 };
 
db.Products.DeleteOnSubmit(product);
 
db.SubmitChanges();

Okay, but it won’t work. The code will gets compiled, but when executed it will throw an exception stating: “Cannot remove an entity that has not been attached.” Well, in fact, it’s quite obvious, because the object context is simply unaware of that object, so let it know about the object. We just need to attach the object to the object context:

NorthwindDataContext db = new NorthwindDataContext();
 
Product product = new Product { ProductID = 1 };
db.Products.Attach(product); //that necessary line
 
db.Products.DeleteOnSubmit(product);
 
db.SubmitChanges();

So, if you compile it now, you will get no exceptions and the necessary product will be removed from the database. You can use the same technique when you need to update an object without having to retrieve it from the database and the same thing applies to the Entity Framework, although the code is slightly different:

NorthwindEntities db = new NorthwindEntities();

Product product = new Product { ProductID = 10 };
product.EntityKey = new EntityKey("NorthwindEntities.Products", "ProductID", 10);
db.Attach(product);

db.DeleteObject(product);

db.SaveChanges();

Posted by Mike Borozdin on Thursday, January 15, 2009 4:12 AM GMT
Shout it Kick it!  
Permalink | Comments (3) | Post RSSRSS comment feed

The List of the LINQ to SQL and Entity Framework Providers

If you are using Microsoft SQL Server you don’t experience any problems, SQL Server are supported by both LINQ to SQL and the Entity Framework. Frankly speaking, it couldn’t be otherwise, since they all are made by Microsoft.

However, if you are using a non-Microsoft database engine, it’s certainly worth knowing if you can use LINQ to SQL or the Entity Framework with it. Moreover, it’s always better if there is native support.

  LINQ to SQL (native) LINQ to SQL (3rd party) Entity Framework (native) Entity Framework
(3rd party)
SQL Server Yes who cares? Yes who cares?
SQl Server CE Yes who cares? Yes who cares
Oracle No DBLinq
LINQ to Oracle
LightSpeed
dotConnect
Yes dotConnect
EFOracle
DB2 No ? Yes ?
MySQL No DBLinq
LightSpeed
Planned dotConnect
PostgreSQL No Npgsql
DBLinq

LightSpeed
dotConnect
No Npgsql
dotConnect

According to the table, the Entity Framework is natively supported by a greater number of databases than plain LINQ to SQL. Anyway, if you cannot find a native provider, you can always find a 3rd party one, but you must remember that some of them are not free and/or may lack some features.

Feel free to correct this table, if it contains a mistake and comment on individual providers. It’s reasonable to keep this list comprehensive. Although I wish every major database would have native support of both technologies.


Posted by Mike Borozdin on Tuesday, January 06, 2009 1:10 PM GMT
Shout it Kick it!  
Permalink | Comments (7) | Post RSSRSS comment feed

Creating Entity Framework Driven ASP.NET Application

Introduction

I have already written several posts on the Entity Framework where I described the power of this particular ORM tool. I also mentioned the book on the Entity Framework written by a Microsoft MVP - Joydip Kanjila. This time I will publish an extract from the book that shows how you can build ASP.NET application by using the Entity Framework and the EntityDataSource control. It can also give a glimpse of the Entity Framework is, if you have no experience in it.

The tutorial covers the following topics:

  • Creating the Entity Data Model by using a graphical utility built-in Visual Studio 2008 SP1
  • Creating the Entity Data Model by using a command line utility
  • Using the EntityDataSource ASP.NET control
  • Displaying the data in a GridView

This tutorial uses a particular database, but in fact you can use any database you already have.

Creating an Entity Data Model.

You can create the ADO.NET Entity Data Model in one of the two ways:

  • Use the ADO.NET Entity Data Model Designer
  • Use the command line Entity Data Model Designer called EdmGen.exe

We will first take a look at how we can design an Entity Data Model using the ADO.NET Entity Data Model Designer which is a Visual Studio wizard that is enabled after you install ADO.NET Entity Framework and its tools. It provides a graphical interface that you can use to generate an Entity Data Model.

Creating the Payroll Entity Data Model using the ADO.NET Entity Data Model Designer

Here are the tables of the 'Payroll' database that we will use to generate the data model:

  • Employee
  • Designation
  • Department
  • Salary
  • ProvidentFund

To create an entity data model using the ADO.NET Entity Data Model Designer, follow these simple steps:

l>
  • Open Visual Studio.NET and create a solution for a new web application project as seen below and save with a name.

  • Switch to the Solution Explorer, right click and click on Add New Item as seen in the following screenshot:

  • Next, select ADO.NET Entity Data Model from the list of the templates displayed as shown in the following screenshot:

            
  • Name the Entity Data Model PayrollModel and click on Add.
  • Select Generate from database from the Entity Data Model Wizard as shown in the following screenshot:

    Note that you can also use the Empty model template to create the Entity Data Model yourself.

    If you select the Empty Data Model template and click on next, the following screen appears:

    As you can see from the above figure, you can use this template to create the Entity Data Model yourself. You can create the Entity Types and their relationships manually by dragging items from the toolbox. We will not use this template in our discussion here. So, let's get to the next step.

  • Click on Next in the Entity Data Model Wizard window shown earlier.
  • The modal dialog box will now appear and prompts you to choose your connection as shown in the following figure:

  • Click on New Connection Now you will need to specify the connection properties and parameters as shown in the following figure:

    We will use a dot to specify the database server name. This implies that we will be using the database server of the localhost, which is the current system in use.

  • After you specify the necessary user name, password, and the server name, you can test your connection using the Test Connection button. When you do so, the message Test connection succeeded gets displayed in the message box as shown in the previous figure.
  • When you click on OK on the Test connection dialog box, the following screen appears:

    Note the Entity Connection String generated automatically. This connection string will be saved in the ConnectionStrings section of your application's web.config file. This is how it will look like:

      <connectionStrings> 
      <add name="PayrollEntities" connectionString="metadata=res:// *;
      provider=System.Data.SqlClient;provider connection string=&quot;
      Data Source=.;Initial Catalog=Payroll;User ID=sa;Password=joydip1@3;
      MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>
  • When you click on Next in the previous figure, the following screen appears:

  • Expand the Tables node and specify the database objects that you require in the Entity Data Model to be generated as shown in the following figure:

  • Click on Finish to generate the Entity Data Model.
  • Here is the output displayed in the Output Window while the Entity Data Model is being generated:

    Your Entity Data Model has been generated and saved in a file named PayrollModel.edmx. We are done creating our first Entity Data Model using the ADO.NET Entity Data Model Designer tool.

    When you open the Payroll Entity Data Model that we just created in the designer view, it will appear as shown in the following figure:

    Note how the Entity Types in the above model are related to one another. These relationships have been generated automatically by the Entity Data Model Designer based on the relationships between the tables of the Payroll database.

    In the next section, we will learn how we can create an Entity Data Model using the EdmGen.exe command line tool.

    Creating the Payroll Data Model Using the EdmGen Tool

    We will now take a look at how to create a data model using the Entity Data Model generation tool called EdmGen.

    The EdmGen.exe command line tool can be used to do one or more of the following:

    • Generate the .cdsl, .msl, and .ssdl files as part of the Entity Data Model
    • Generate object classes from a .csdl file
    • Validate an Entity Data Model

    The EdmGen.exe command line tool generates the Entity Data Model as a set of three files: .csdl, .msl, and .ssdl. If you have used the ADO.NET Entity Data Model Designer to generate your Entity Data Model, the .edmx file generated will contain the CSDL, MSL, and the SSDL sections. You will have a single .edmx file that bundles all of these sections into it. On the other hand, if you use the EdmGen.exe tool to generate the Entity Data Model, you would find three distinctly separate files with .csdl, .msl or .ssdl extensions.

    Here is a list of the major options of the EdmGen.exe command line tool:

    Option

    Description

    /help

    Use this option to display help on all the possible options of this tool. The short form is /?

    /language:CSharp

    Use this option to generate code using C# language

    /language:VB

    Use this option to generate code using VB language

    /provider:<string>

    Use this option to specify the name of the ADO.NET data provider that you would like to use.

    /connectionstring:

    <connection string>

    Use this option to specify the connection string to be used to connect to the database

    /namespace:<string>

    Use this option to specify the name of the namespace

    /mode:FullGeneration

    Use this option to generate your CSDL, MSL, and SSDL objects from the database schema

    /mode:EntityClassGeneration

    Use this option to generate your entity classes from a given CSDL file

    /mode:FromSsdlGeneration

    Use this option to generate MSL, CSDL, and Entity Classes from a given SSDL file

    /mode:ValidateArtifacts

    Use this option to validate the CSDL, SSDL, and MSL files

    /mode:ViewGeneration

    Use this option to generate mapping views from the CSDL, SSDL, and MSL files




    Entity Framework Tutorial
    Entity Framework Tutorial Learn to build a better data access layer with the ADO.NET Entity Framework and ADO.NET Data Services
    • Clear and concise guide to the ADO.NET Entity Framework with plentiful code examples
    • Create Entity Data Models from your database and use them in your applications
    • Learn about the Entity Client data provider and create statements in Entity SQL
    • Learn about ADO.NET Data Services and how they work with the Entity Framework

    http://www.PacktPub.com/entity-framework-tutorial/book



    Note that you basically need to pass the connection string, specify the mode, and also the project name of the artifact files (.csdl, .msl, and the .ssdl files) to be created. To create the Entity Data Model for our database, open a command window and type in the following:

    edmgen /mode:fullgeneration /c:"Data Source=.;Initial Catalog=Payroll;User ID=sa;
    Password=joydip1@3;" /p:Payroll

    This will create a full ADO.NET Entity Data Model for our database. The output is shown in the following figure:

    You can now see the list of the files that have been generated:

    You can validate the Payroll Entity Data Model that was just created, using the ValidateArtifacts option of the EdmGen command line tool as shown below:

    EdmGen /mode:ValidateArtifacts /inssdl:Payroll.ssdl /inmsl:Payroll.msl /incsdl:Payroll.csdl

    When you execute the above command, the output will be similar to what is shown in the following figure:

    As you can see in the previous figure, there are no warnings or errors displayed. So, our Entity Data Model is perfect.

    The section that follows discusses the new Entity Data Source control which was introduced as part of the Visual Studio.NET 2008 SP1 release.

    The ADO.NET Entity Data Source Control

    Data controls are those that can be bound to data from external data sources. These data sources may include databases, XML files, or even flat files. ASP.NET 2.0 introduced some data source controls with a powerful data binding technique so the need for writing lengthy code for binding data to data controls has been eliminated.

    In ASP.NET, the term Data Binding implies binding the controls to data retrieved from a data source and providing a read or write connectivity between these controls and the data that they are bound to.

    The Entity Data Source control is an example of a data control that is included as part of the Visual Studio 2008 SP1 release and can be used to bind data retrieved from an Entity Data Model to the data bound controls of ASP.NET. If you have installed Visual Studio 2008 SP1, you can see the EntityDataSource control listed in the Data section of your toolbox.

    If you cannot locate the EntityDataSource control in the toolbox, follow these steps:

    1. Right-click on the Toolbox and select the Choose Items option as shown in the following figure:

              
    2. From the list of the components displayed, scroll down to locate the EntityDataSource in the .NET Framework Components tab. Refer to the following figure:

    3. Now, check the checkbox next to the EntityDataSource component and click on OK.

    The ADO.NET Entity Data Source control is now added to your toolbox as shown in the following figure:

    If the EntityDataSource component is not listed in the list of the componentsdisplayed in the Choose Toolbox Items window, you will have to add it manually. To do this, click on the Browse button in the Choose Toolbox Items window, locate theSystem.Web.Entity.dll in the folder in your system where Microsoft .NET Framework 3.5 has been installed and click on OK.

    Implementing Our First Application Using the Entity Framework

    In this section, we will learn how to use the Entity Data Model and the Entity Data Source Control to implement our first program using the Entity Framework. We will use a GridView control to display bound data.

    Refer to the solution we created earlier using the Entity Data Model Designer. Now, follow these steps:

    1. Drag and drop an Entity Data Source control from the toolbox onto your  Default.aspx web form.
    2. Now, click on the Configure Data Source option to specify the data source. Refer to the following figure:

    3. Specify the Connection String and DefaultContainerName and then click on  Next.
    4. Specify the fields you would want to retrieve from the database table and click on Finish when done.
    5. Now, drag and drop a GridView control from the toolbox onto the  Default.aspx web form as seen in the following figure:

    6. Next, use the Choose Data Source option of the GridView control to associate its data source with the Entity Data Source control we created earlier. Refer to the following figure:

    Here is how the markup code of the GridView control looks with its templates defined. Note how the DataSourceID of the GridView control has been associated with the Entity Data Source control we created earlier.

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="EmployeeID" 
    DataSourceID="SqlDataSource1" BorderColor="Black" BorderStyle="Solid" Width="400px">
    <Columns>
    <asp:BoundField DataField="EmployeeID" HeaderText="Employee ID" ReadOnly="True"
    SortExpression="EmployeeID" />
    <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
    <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
    <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
    </Columns>
    </asp:GridView>

    We are done! When you execute the application, your output should be similar to what is shown in the following figure:




    Entity Framework Tutorial
    Entity Framework Tutorial Learn to build a better data access layer with the ADO.NET Entity Framework and ADO.NET Data Services
    • Clear and concise guide to the ADO.NET Entity Framework with plentiful code examples
    • Create Entity Data Models from your database and use them in your applications
    • Learn about the Entity Client data provider and create statements in Entity SQL
    • Learn about ADO.NET Data Services and how they work with the Entity Framework


    http://www.PacktPub.com/entity-framework-tutorial/book



    About the Author

    Joydip Kanjilal is a Microsoft MVP in ASP.NET. He has over 12 years of industry experience in IT with more than 6 years in Microsoft .NET and its related technologies. He has authored many articles for some of the most reputable sites like,www.asptoday.com, www.devx.com, www.aspalliance.com, www.aspnetpro.com, www.sql-server-performance.com, www.sswug.com, etc. Several of these articles have been featured at www.asp.net—Microsoft's Official Site on ASP.NET. Joydip was also a community credit winner at www.community-credit.com a number of times.

    He is currently working as a Senior Consultant in a reputable company in Hyderabad, INDIA. He has years of experience in designing and architecting solutions for various domains. His technical strengths include C, C++, VC++, Java, C#, Microsoft .NET, Ajax, Design Patterns, SQL Server, Operating Systems, and Computer Architecture. Joydip blogs at http://aspadvice.com/blogs/joydip and spends most of his time reading books, blogs, and writing books and articles. His hobbies include watching cricket and soccer and playing chess.


    Posted by Mike Borozdin on Saturday, January 03, 2009 6:44 AM GMT
    Shout it Kick it!  
    Permalink | Comments (4) | Post RSSRSS comment feed