Showing posts with label Entity Framework 4. Show all posts
Showing posts with label Entity Framework 4. Show all posts

Sunday, June 6, 2010

Visual Studio 2010 and .NET Framework 4 Training Kit


From Microsoft's web site, here is a training course material (165 Mb) to learn when ever you want (it takes about 3 days full time).

FREE Visual Studio 2010 and .NET Framework 4 Training Kit


Day 1
  • Lap Around Visual Studio 2010 (PPT: What's New In Visual Studio 2010)
  • Lap Around .NET Framework 4 (PPT: Whats New In .NET Framework 4)
  • Managed Languages Overview (C#/VB) (PPT: What's New In C# 4 and Visual Basic 10)
  • Entity Framework 4 (PPT: Whats New In Entity Framework 4)
  • ADO.NET Data Services 1.5 (PPT: Whats New In ADONET Data Services 1.5)
  • Velocity (PPT: Introduction to Project "Velocity")
  • Silverlight 3 (PPT: Not included in the kit)

Day 2
  • ASP.NET 4 (PPT: Whats New In ASP.NET Web Forms 4)
  • AJAX 4 (PPT: Whats New In ASP.NET AJAX 4)
  • Web Deployment with Visual Studio 2010 (PPT: Web Deployment with Visual Studio 2010)
  • Windows Presentation Foundation 4 (PPT: What's New in Windows Presentation Foundation 4)
  • .NET RIA Services (PPT: Introduction to .NET RIA Services)
  • Managed Extensibility Framework (PPT: Introduction to the Managed Extensibility Framework)

Day 3
  • WF/WCF 4 (PPT: Workflow 4: A First Look)
  • Parallel Computing with Visual Studio 2010 (PPT: Parallel Computing with Visual Studio 2010)
  • Parallel Computing for Managed Developers (PPT: Parallel Computing for Managed Developers)
  • Visual Studio Team System 2010
  • These are short modules that can be picked based on the interest of the audience.
         . PPT: Introduction: Visual Studio Team System 2010    . PPT: No More Planning Black Box    . PPT: No More Late Surprises    . PPT: No More Stakeholder Surprises    . PPT: No More Parallel Development Pain    . PPT: No More Bewildering Admin    . PPT: No More No Repro
  • Visual Studio Team System 2010
    •    . PPT: No More Build Breaks    . PPT: No More Butterfly Effect    . PPT: No More UI Regressions    . PPT: No More Missed Requirements or Changes    . PPT: No More Waiting for Build Setup    . PPT: No More Performance Regressions

Sunday, December 6, 2009

A business oriented drawing application made easy with Entity Framework 4

Hi, here is a basic example of how to design a generic business oriented drawing application using Entity Framework 4. The Client of the Entity model could be a Silverlight or WPF application, using RIA Services for instance (although so far RIA Services has some limitations).

(On this example, my project uses an ASP.Net front office, just to validate that it also works easily)

Consider the following edmx model :


After connecting to a Database and generating all tables from the model ("Generate Database Script from Model..."), the EF also magically generates all the C# classes for you. It's a nice and clean code that you can directly use :


protected void Page_Load(object sender, EventArgs e)
{

    EFModelContainer BusinessContainer = new EFModelContainer();

    Screen screen = new Screen() { Guid = Guid.NewGuid(), Name = "My Screen" };
    Tab tab = new Tab() { Guid = Guid.NewGuid(), Name = "My Tab" };


    BlockElementary elementaryBlock1 = new BlockElementary() { Guid = Guid.NewGuid(), Name = "My elementaryBlock1" };
    BlockElementary elementaryBlock2 = new BlockElementary() { Guid = Guid.NewGuid(), Name = "My elementaryBlock2" };
    BlockElementary elementaryBlock3 = new BlockElementary() { Guid = Guid.NewGuid(), Name = "My elementaryBlock3" };

    BlockContainer blockContainer1 = new BlockContainer() { Guid = Guid.NewGuid(), Name = "My BlockContainer1" };
    BlockContainer blockContainer2 = new BlockContainer() { Guid = Guid.NewGuid(), Name = "My BlockContainer2" };

    // Adds the elementary blocs to the container
    // NOTE : I know this is not proper English,
    // but I prefer this way for intellisens purposes
    blockContainer1.BlockElementaries.Add(elementaryBlock1);
    blockContainer1.BlockElementaries.Add(elementaryBlock3);

    blockContainer2.BlockElementaries.Add(elementaryBlock1);
    blockContainer2.BlockElementaries.Add(elementaryBlock2);
    blockContainer2.BlockElementaries.Add(elementaryBlock3);

    atmTextBlock atomTB = new atmTextBlock()
{ Guid = Guid.NewGuid(), Name = "My atmTextBlock" };
    atomTB.Label = "Label of my atome of type TextBlock atomTB";

    atmTextBlock atomTB2 = new atmTextBlock()
{ Guid = Guid.NewGuid(), Name = "My atmTextBlock" };
    atomTB2.Label = "Label of my atome of type TextBlock atomTB2";


    elementaryBlock1.Atoms.Add(atomTB);
    elementaryBlock2.Atoms.Add(atomTB2);

    // NOTE : I should be renaming tab.BlockContainer into tab.BlockContainers
    tab.BlockContainer.Add(blockContainer1);
    tab.BlockContainer.Add(blockContainer2);
    screen.Tabs.Add(tab);

    BusinessContainer.AddToEltOfScreens(screen);
    int countUpdates = BusinessContainer.SaveChanges();

    Response.Write("Number of updates = " + countUpdates);

}

Everything saves properly into the database :

Thursday, December 3, 2009

Entity Framework combined with Class Diagrams

You liked the Class Diagrams in Visual Studio ? Use them with Entity Framework !!

Here is how :

1/ Use your favorite Developper's environment to create your Entity models (and the dependencies and inheritance as required). Let us assume that your file is called BusinessModel.edmx :



2/ Save the model. This will generate automatically the classes associated with the entities,

3/ Create a Class Diagram, call it for instance ClassDiagram.cd

4/ Open the Class View panel and drill down to find your classes, then Drag and Drop your classes either one by one or by selecting many of them onto the ClassDiagram.cd diagram.




5/ By default, the diagram is read only, and all properties / items are grayed out.



This is because it was generated by EF4;
Create a new file, called for instance 'BusinessModelParialClasses.cs'
that is going to extend the partial EF generated classes stored in the BusinessModel.Designer.cs

6/ You can extend the classes within the 'BusinessModelParialClasses.cs' file, for example, add the two following methods :
public bool TurnPages(int NumberOfPagesToTurn) ...
public bool TurnChapter(int NumberOfChapterToTurn) ...

on the Book class.

7/ You can notice that now the Class Diagram of the Book Class is not fully read only anymore (the elements generated by EF4 are still read only), and offers the 'Add' option like you are used to:


8/ Obviously, you can access all the Class Details pan properties, like you normally would.


9/ That's it ! let's go back to your Edmx file, where you can "Generate Database Script from Model". And here you go, nearly zero line of code !!!

How lazy I am, more over, a snap shoot of the display and copy/paste will create a nice documentation.
Well ideally, the best would be to generate a dynamic Silverlight 3.0 image within a web document hosted on a Web server ;-) Sounds like SharePoint 2010 ??




Note: This was used with Visual Studio 2010 Beta + EntityFramework 4