Jul 302012
 

This is probably a bit of a late announcement, but Microsoft has elected to make the Entity Framework an Open Source project on CodePlex!  The first officially supported packages (from the open source project) are  rumoured to be integrated as of Entity Framework v6 (as the Entity Framework team are currently working on version 5).

The main reason for the move to open source, evidentially, is to allow the developer community to build more providers for the Entity Framework.  This would allow potentially any database (or database alternative) to be used with an Entity model.  Exciting!

If you want to check out the current status of the Entity Framework (both Database-first and Code-first) you can download the Entity Framework 5 Release Candidate via Visual Studio’s distributed Package Manager -  NuGet.  The latest version includes a number of improvements and additions including (FINALLY!) support for Enums.

I might consider writing a separate article on the installation and use of NuGet just in case there are folks out there who haven’t installed and used it yet.  If you are interested in an article on using NuGet please leave a comment here.

To find out more about what is coming in the next version of the Entity Framework v5 check out the following link.  Here’s what I gleaned from the overview:  Note that it doesn’t appear that v5 will contain support for “Navigation Properties” (Foreign Keys/Relationships) from Unique Constraints!!

What’s New in EF5?

EF 5 includes bug fixes to the 4.3.1 release and a number of new features. Most of the new features are only available in applications targeting .NET 4.5, see the Compatibility section for more details.

  • Enum support allows you to have enum properties in your entity classes. This new feature is available for Model, Database and Code First.
  • Table-Valued functions in your database can now be used with Database First.
  • Spatial data types can now be exposed in your model using the DbGeography and DbGeometry types. Spatial data is supported in Model, Database and Code First.
  • The Performance enhancements that we recently blogged about are included in EF 5.
  • Visual Studio 11 includes LocalDb database server rather than SQLEXPRESS. During installation, the EntityFramework NuGet package checks which database server is available. The NuGet package will then update the configuration file by setting the default database server that Code First uses when creating a connection by convention. If SQLEXPRESS is running, it will be used. If SQLEXPRESS is not available then LocalDb will be registered as the default instead. No changes are made to the configuration file if it already contains a setting for the default connection factory.

The following new features are also available in the Entity Model Designer in Visual Studio 11 Beta:

  • Multiple-diagrams per model allows you to have several diagrams that visualize subsections of your overall model.
  • Shapes on the design surface can now have coloring applied.
  • Batch import of stored procedures allows multiple stored procedures to be added to the model during model creation

References

Open Source Announcement
[ http://weblogs.asp.net/scottgu/archive/2012/07/19/entity-framework-and-open-source.aspx ]

Entity Framework on Codeplex
[ http://entityframework.codeplex.com/ ]

Announcement about Entity Framework 5 (RC) available via NuGet
[ http://blogs.msdn.com/b/adonet/archive/2012/05/15/ef5-release-candidate-available-on-nuget.aspx ]

Introduction to EF (Database-First)
[ http://blogs.msdn.com/b/adonet/archive/2011/09/28/ef-4-2-model-amp-database-first-walkthrough.aspx ]

NuGet Entity Framework Package
[ http://nuget.org/packages/EntityFramework/ ]

NuGet: How to use the Package Manager
[ http://docs.nuget.org/docs/start-here/using-the-package-manager-console ]

Installing NuGet
[ http://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c ]

Jul 252012
 

Hi All.  This is a quick post to introduce you to SQL Server Data Tools – support and tools for database developers.

image

Introduction

Recently, I started a new solution in Visual Studio 2010.  There is a need to build and maintain a database schema (for SQL Server 2008 R2), so I decided to add what was once formerly known as “DataDude” – the Database Project for Visual Studio.

This was in a copy of Visual Studio Professional 2010 with Service Pack 1 – and the out-of-the-box solution only supported SQL Server 2008 and prior.  A bit surprised, I did some digging.  You’ll recall there was a ‘Database Edition GDR’ which came out a few years back..  well there’s now an even better flavour of support.

Introducing SQL Server Data Tools

It’s called ‘Microsoft SQL Server Data Tools’ and you can get a copy from the following link on MSDN.  There are quite a number of new bits and pieces included, and it works with both Visual Studio 2010 (alert: apply Service Pack 1 beforehand) or Visual Studio 2012 (RC – although with some known issues if upgrading from, the beta).

Although the installation takes a little while (depending on your connection speed), the wait is worthwhile.

image

I’ll borrow some text from the MSDN site in order to explain the purpose of SSDT:

Who is SSDT for, and what does it provide them?

SSDT is for SQL Server database developers, who often develop database schemas, views, stored procedures, and other database objects while developing their application logic.

  • Tooling for both SQL Server and SQL Azure Development: SSDT offers new capabilities in a single cohesive environment to compile, refactor, and deploy databases to specific editions of SQL Server and SQL Azure. The toolset makes it easy, for example, to migrate on-premise SQL Server schemas to the cloud on SQL Azure, and develop and maintain databases across both on premise and cloud deployments. SSDT can target SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, and SQL Azure databases, including all editions of these database servers.
  • For SQL Server DBAs: SSDT provides a central and unified toolset targeted to the specific needs of DBAs to develop and maintain databases, with visual tools for developing tables, schema compare, and rich T-SQL support for refactoring databases, building views, stored procedures, functions and triggers. The toolset provides both a live development mode, and an offline project mode that tracks and manages all artifacts associated with a database. This mode optionally fully integrates with Visual Studio 2010 for team development, source control and change tracking. All change operations are automatically transformed into optimized T-SQL alter scripts, and can optionally be applied immediately to the online database or saved for later execution.

[http://msdn.microsoft.com/en-us/data/hh322942]

It’s actually very easy to use. 

Real World Applications

For example, if you open a solution containing legacy database projects the tools will automatically prompt you as to whether you wish to upgrade your existing database projects to the newer edition.

The basic benefit is targeting SQL Server 2008 (and R2) as well as SQL Server 2012 and SQL Azure.  That last part might get your attention! That’s right – SQL Azure.  We’ll be checking this out soon and reporting back in a bit more detail. 

How Do I get SSDT?

You can download the “pre-installer” here.

For more information, check out the ‘Getting Started with SQL Data Tools’ located here.. or stay tuned at this location for more!

But wait.. there’s a bug?

Today I got into full swing with the SSDT and a real world project.  During my work I came across a fairly horrible bug which has been documented on the MSDN Forums.

Basically, if you initialize (i.e. use) any of the SSDT tools you can’t use the Entity Framework tools and vice-versa.  The interim workaround is to load two instances of Visual Studio (perhaps even the same solution?) and use the SSDT tools in the first instance, and the Entity Framework tools in the other.

A symptom which might lead you to this article?  When you have the SQL Server Data Tools installed, and try to update or create an Entity Framework data model – you may receive errors such as ‘Object not set’ etc.  In some cases it might crash the VS IDE.  In my experience, I received the ‘object not set’ errors, and the Model Explorer was greyed/did not render.  I was also not able to refresh my EDMX properly.

Whilst being a right royal pain in the butt, believe it or not this approach does work – even if it does make for a very disjointed development experience.  According to the thread, a fix is in the works – but no word on when it will be released.

Mar 082012
 

image

Overshadowed, possibly, by the release of the new iPad?  Not in the world of databases.  Yesterday Microsoft officially released SQL Server 2012 “release to manufacturing” (RTM) which means we’re officially out of pre-release editions!

Previously codenamed ‘Denali’, the new version brings to the table some serious changes, some of which have already been documented elsewhere.  If you’re keen to jump right in, here’s a link to the Evaluation version (released 06/03/2012 – RTM).  Those with MSDN accounts should be able to download from the MSDN Subscriptions site.

For those who want something a little less heavy, SQL Server 2012 has been shipped in the Express Edition form, an amazing deal for those looking for Enterprise performance and features, but who can’t afford the full blown solution.

ZDNet has some coverage on the launch here, and some more details around the 2012 Edition can be found here.  Of interest (particularly to me) is the integration with Apache Hadoop, which I’ve previously started to research (notes here).

If you are curious about what to expect in SQL Server 2012, a trip to the “What’s New?” page might satisfy – http://social.technet.microsoft.com/wiki/contents/articles/3783.what-s-new-in-sql-server-2012.aspx

As soon as I can, I’ll post another article with some info as I put the new edition through its paces.  I’m excited about some of the interop potential, plus the opportunity to take the updated Master Data Services (new in the previous edition) and the new Data Quality Services for a spin.

Here’s some snippets I’m interested in, from the TechNet site:

New: to SQL Server 2012

Introducing Data Quality Services

SQL Server 2012

The data-quality solution provided by Data Quality Services (DQS) enables a data steward or IT professional to maintain the quality of their data and ensure that the data is suited for its business usage. DQS is a knowledge-driven solution that provides both computer-assisted and interactive ways to manage the integrity and quality of your data sources. DQS enables you to discover, build, and manage knowledge about your data. You can then use that knowledge to perform data cleansing, matching, and profiling. You can also leverage the cloud-based services of reference data providers in a DQS data-quality project.

Enhancement: Programming Changes

14 New Functions and 1 Changed Function

SQL Server 2012 introduces 14 new built-in functions. These functions ease the path of migration for information workers by emulating functionality that is found in the expression languages of many desktop applications. However these functions will also be useful to experienced users of SQL Server.

The new functions are:

Conversion functions

Date and time functions

Logical functions

String functions

In addition to the 14 new functions, one existing function has been changed. The existing LOG (Transact-SQL) function now has an optional second base parameter.

Enhancement: SQL Server Express LocalDB

SQL Server Express LocalDB is a new lightweight edition of Express that has all its programmability features, yet runs in user mode and has a fast, zero-configuration installation and short list of pre-requisites. The LocalDB edition of SQL Server is targeted to program developers. LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine.

Once LocalDB is installed, developers initiate a connection by using a special connection string. When connecting, the necessary infrastructure is automatically created and started, enabling the application to use the database without complex or time consuming configuration tasks.

Developer Tools can provide developers with a SQL Server Database Engine that lets them write and test Transact-SQL code without having to manage a full server instance of SQL Server. An instance of SQL Server Express LocalDB can be managed by using the SqlLocalDB.exe utility. SQL Server Express LocalDB should be used in place of the SQL Server Express user instance feature which is deprecated. For more information, see SQL Server 2012 Express LocalDB.

Enhancements: SQL Server Management Studio

SQL Server Management Studio introduces the following features in SQL Server 2012:

  • SQL Server Management Studio supports two keyboard shortcut schemes. The new default keyboard shortcuts are based on the Microsoft Visual Studio 2010 keyboard shortcuts. You can also configure Management Studio to use the keyboard shortcuts from SQL Server 2008 R2. SQL Server 2012 no longer includes the SQL Server 2000 Enterprise Manager shortcuts. For more information, see SQL Server Management Studio Keyboard Shortcuts.

  • The Database Engine Query Editor introduces enhanced functionality for Transact-SQL debugging and IntelliSense.

    • The Transact-SQL debugger introduces the following new features:

      • You can now debug Transact-SQL scripts running on instances of SQL Server 2005 Service Pack 2 (SP2) or later.

      • Transact-SQL breakpoints now support the following functionality:

        • A breakpoint condition is a Transact-SQL expression whose evaluation determines whether the breakpoint is invoked. For more information, see Specify a Breakpoint Condition.

        • A breakpoint hit count specifies the number of times a breakpoint is encountered before it is invoked. For more information, see Specify a Hit Count.

        • A breakpoint filter limits the breakpoint to operating only on specified computers, processes, or threads. For more information, see Specify a Breakpoint Filter.

        • A breakpoint action specifies a custom task that is performed when the breakpoint is invoked. For more information, see Specify a Breakpoint Action.

        • You can edit a breakpoint location to move a breakpoint from one Transact-SQL statement to another. For more information, See Edit a Breakpoint Location.

      • The Watch window and Quick Watch now support watching Transact-SQL expressions. For more information, see Transact-SQL Debugger Information.

      • When you move the cursor over a Transact-SQL identifier, a Quick Info pop up displays the name of the expression and its current value. For more information, see Transact-SQL Debugger Information.

    • Transact-SQL IntelliSense introduces the following new features:

      • Breakpoint validation prevents setting a breakpoint in an invalid location.

      • Transact-SQL code snippets are templates you can use as starting points when building Transact-SQL statements in batches and scripts. For more information, see Insert Transact-SQL Snippets.

      • Transact-SQL Surround with snippets are templates you can use as staring points when enclosing sets of Transact-SQL statements in a BEGIN, IF, or WHILE block. For more information, see Insert Surround-with Transact-SQL snippets.

    • Many known database restore issues and enhancements requested by customers have been addressed. The major enhancements include:

      • The algorithm used to construct restore plans has improved significantly and a lot of edge cases, including forking scenarios, are dealt with more efficiently than in previous versions of SQL Server.

      • Point-in-time restore has been improved by the addition of a visual timeline that allows you to identify a feasible point in time as a target time for a database restore operation. When you select a point in time, a restore plan that includes setting relevant restore operations is automatically generated. For more information, see Restore a Database Backup (SQL Server Management Studio).

    • The new Page Restore dialog enables you to check database pages for corruption and to restore selected corrupt pages from a database backup and subsequent log backups. For information about page restore, see Restore Pages (SQL Server).

There’s so much more.. check it out today.