All posts by Julie

New Blog and New WebSite!

I’ve finally done away with my ancient asp.net 2.0 thedatafarm.com that I hadn’t paid any attention to in many years and with it also moved my blog (an early version of graffitiCMS that was starting to act up).

Both are now set up as a WordPress app which was fun to configure with plugins and widgets and not too challenging since I have played with WordPress a bit on behalf of my mom.

So this will be easier for me to maintain and add in modern goodies like the social links.

I’m grateful to a number of people who’s resources helped or inspired me:

Picking a Blog Engine

Many folks on twitter recommended their favorite blog engine. I considered Orchard, the new Ghost blog and initially thought I did not want to use WordPress. My pal Daniel Marbach worked on me on twitter for a while, mystified why I was a brick wall about my anti-Wordpress stance. (He gets the last laugh!) Ghost is new. It will run on Windows Azure. But I was staying with orcsweb (via Cytanium) and that was not an option. Michele Bustamante is loving Ghost on her new site michelebusta.com. Sebastien Ros, from Microsoft, who works on Orchard, was very supportive, even offering to do the big 10 year, 4200 blog post conversion for me. In the end, Steve Smith said two words that swayed me back to WordPress: automatic updates. Yeah I love the ease of one button click wordpress and plugin updates.

Picking a Host

I’ve been very fortunate to have my site hosted by orcsweb.com for many years. While they are one of the highest-end hosts for ASP.net sites and pricey (but oh so worth it), they had offered me free hosting as a benefit of being an ASPInsider. Otherwise, it would have been overkill for my wee web site. But thanks to the gratis hosting, I get the benefits that orcsweb has to offer. Orcsweb has a spin-off company for people like me …don’t need the power (or expense) of the premier hosting, but still want the benefit of their experience, dependibility and great customer support: Cytanium.com. So they offered to host my site on Cytanium which also sports the  Microsoft Web App Gallery for auto creating websites using frameworks like Orchard and WordPress. There are about 100 apps to choose from to install from the gallery. Setting up a new WordPress site was a snap.

Migrating 10 years worth of blogging

I have over 4000 blog posts and didn’t want to lose them. I found four resources that made this possible.

  1. Jef Kazimer‘s blog post on his Graffiti to WordPress migration was very helpful.
  2. Jon Sagara‘s Graffiti to BlogML tool. It’s just a small project that you can download and run in Visual Studio. I made one tweak to the code which was to handle some issues with the way it tried to emulate the blog URLs based on the titles. I had lots of quotations in those titles. In the end, I didn’t even need those URLs becasue I figured out how to get WordPress to format URLs just the same as they were formatted in the graffiti so my links should all (or mostly all) work. And I got the tool to create valid XML. I pointed the connection string to my sql server database and it processed all of the blog posts and comments in a matter of minutes!
  3. Once the posts are in BlogML format there is a WordPress plugin, BlogML Importer (which works fine with WordPress 3.8), that does the conversion.
  4. However it has a limit of 2MB file imports. Searching for a solution, I couldn’t believe that it was my own old Vermont pal, Dave Burke, who presented the solution Importing a Big Honkin’ BlogML.xml Into WordPress . I followed his instructions to a T and was able to pull in all of my posts and comments in 7 smaller files.

And some marketing

I left my blog in a /blog subfolder so that I can continue to have a main page on thedatafarm.com to let folks know that, as a consultant, I do like (and need) to work for a living.  It is all just one big wordpress site. Well, really a small one. The other stuff, home page, etc , are just static pages.

Plugins

I’m using a bunch of plugins. Since they are free, the least I can do is give them a nod:

plugins

 

Problems Installing AMD Catalyst Control Center on Windows 8? Here’s my fix!

TLDR: Updating to Windows 8.1 and reinstalling solved the problem. Smile

(And yes, I realize that I just wrote an UpWorthy-worthy post title!)

I recently replaced my 19” monitors with a pair of 27” monitors. My desktop is a Dell Optiplex and it has an AMD HD Radeon 7500 display adapter installed. This came with the Dell and is not an off-the-shelf card, but something that AMD sells generically to manufacturers.

My monitor has HDMI and DisplayPort outputs. My adapter has DisplayPort and DVI inputs. I plugged one monitor DP to DP. It was fine. For some reason, I got an HDMI to DVI adapter instead of a DisplayPort to DVI and when I plugged the second monitor in from the HDMI output, I got what is a classic problem with HDMI monitors: a 1” black border around my desktop window.

I tried many things via windows settings but none did the trick. The monitor has lots of hardware settings but it doesn’t have the classic Horizontal and Vertical scaling option that I’m used to from older monitors.

So I went to the internet and found many (many many many) recommendations on the web to just install AMD’s catalyst control center and then use it’s features to change the scaling on the monitor and lose the border.

Obviously this was the way to go. But after 4 hours of attempting to install the CCC software, I got bupkus. The installer went through the motions of installing but I did not get the CCC menu option on the desktop context menu. This is what it should look like:

image

I went through uninstalls, reinstalls, registry purges (based on AMD guidance), installing beta software. Still nothing.

Then I dug into the install folder created by the installer (C:\AMD) and dug through sub folders running all of the installers I could find! (Yes I know…dangerous and potential for having to repave my machine).

This finally installed a shell of the CCC though still not on my context menu. But when I ran this shell, all it had in it was a Quadrant tool that lets you define where on the screen various softare should be displayed.

I gave up on this thinking that next time I was in town, I would just get a proper DisplayPort to DVI adapter.

A month went by and I decided to try again yesterday. I only wasted 1/2 hr this time before giving up.

I also happened to decide it was time to upgrade this computer from Windows 8 to Windows 8.1. I had upgraded all of the other laptops and devices already.

After the 8.1 update was done, I decided to give CCC one last try (or at least what I was calling one last try.) I looked in the install folder and saw something I had never seen before in my many visits to that folder! A folder called WU-CCC2

image

In there was another install folder and in there another setup.exe!

image

Of course, I gave this a try and the install (because I just love to click on things!) and it did some interesting things. First it ran an uninstall (cleaning up previous garbage?) and then ran another install.

When complete, I had to reboot and the Catalyst Control Center option was finally on my menu!

I opened it up and it looked like all of the screenshots I had seen all over the internet as a recommendation on how to solve my original problem: the 1” border.

And changing the scaling on that monitor, has indeed, fixed the border problem! Smile

image

Sometimes being a pit bull pays off. On the other hand, a new display adapter would have probably been more cost effective than the wasted time …but my pride was at risk, here. So I had to solve the puzzle!

Fix for VS2013 Not Showing Databases in SQL Server Object Explorer

This really had me confused. I have used SSOE plenty in VS2012 and on my laptop that I just replaced, in VS2013. But on my new laptop and on my desktop, I can go through the motions of adding the (localdb)/v11 database to SSOE with no errors and still, nothing shows up under the SQL Server branch of the tree.

Finally I opened VS2012 to see if *it* would show my databases in SSOE. Instead I got a message that SQL Server Data Tools (SSDT) was out of date.

SSDT is an extension to Visual Studio 2012 which that team was releasing whenever they had updates to it.

But for VS2013, it’s just a part of the full IDE.

My out-of-date VS2012 SSDT was causing a conflict with the built in tools for VS2013. Go figure. But installing the October 2013 update to SSDT (you’ll find an update for VS2010 and for VS2012) fixed the problem. Now I can see my databases in SSOE in both version of visual studio.

image

How EF6 Enables Mocking DbSets more easily

There’s an interesting change in EF6 that simplifies unit testing when EF is in the way and you don’t want to engage it at all.

EF6 DbSet gained new features. The team had to decide if they would make a breaking change to the existing IDbSet interface or leave that be and just change DbSet. They chose

the latter route. In doing so, they also ensured that we could use the DbSet directly for testing by adding a new constructor.

Here’ you can see the different constructors and how they affect our ability to test.

EF5 DbSet Constructor

The DbSet constructor is tied to a DbContext by way of the InternalQuery that is used internally in the constructor.

internal DbSet(InternalSet<TEntity> internalSet)
   : base((IInternalQuery<TEntity>) internalSet)
 {
   this._internalSet = internalSet;
 }

In  EF5, we also have IDbSet (DbSet derives from this) (and IObjectSet which was introduced in EF4) . These interfaces contain the set operations (Add, Update, Remove and some additional methods through other interfaces) and can be implemented without forcing any ties to EF’s DbContext.

That’s what we’ve used in the past to create fake DbSets for testing scenarios.

EF6 DbSet Constructors

The internal constructor is still there.

    internal DbSet(InternalSet<TEntity> internalSet)
      : base((IInternalQuery<TEntity>) internalSet)
    {
      this._internalSet = internalSet;
    }

But now there is another constructor. It’s protected and only uses an set interface, but not the query interface. This allows mocking frameworks to get access to DbSet and at the same time, benefit from some of the methods added to DbSet for EF6.

 

  /// <summary>
  /// Creates an instance of a <see cref="T:System.Data.Entity.DbSet`1"/> when called from the constructor of a derived
  ///             type that will be used as a test double for DbSets. Methods and properties that will be used by the
  ///             test double must be implemented by the test double except AsNoTracking, AsStreaming, an Include where
  ///             the default implementation is a no-op.
  /// 
  /// </summary>
  protected DbSet()
    : this((InternalSet<TEntity>) null)
  {
  }

Even if you wanted to create your own fakes (or test doubles) in EF6, you can do that with DbSet now, not IDbSet. IDbSet is still there for backwards compatibility.

There are two detailed documents on MSDN for using EF6 to create Test Doubles and to use with Mocking Frameworks.

You also might find the meeting notes about this change interesting. I sure do! 🙂

I am curious to revisit my work with Telerik’s JustMock. I built some tests with EF5 and JustMock in my Automated Testing for Fraidy Cats course on Pluralsight. When using the paid version, everything just works. But when using JustMock Lite, the free version, it was not able to grok DbSets and you still needed to implement your own fake. I’ll be checking to see if the new DbSet implementation allows the free version of JustMock to mock DbSets on it’s own now.

//update about 20 minutes after initial post. The limitation of JustMock Lite is that it doesn’t support ReturnsCollection which is what you want to emulate the return of a DbSet. So if you’re not willing to pay for your tools, you can use the free version (which has a ton of features) and do a little extra work (create your own test double for DbSet which you can see how to do in MSDN doc I linked to above.

Testing Out the Connection Resiliency Feature into EF6

A few days ago I wrote a blog post about gaining a better understanding of the new connection resiliency feature of EF6. The feature is implemented using an implementation of a new class, IDbExecutionStrategy.

The SQl Server provider that’s bundled with EF6 has a strategy aimed at Windows Azure SQL Database (aka SQL Azure) that is designed to retry a command if a transient connection error is thrown. My blog post listed the transient error messages.

I wanted to see this in action but it’s not simple to make a transient error occur. There was a blog post with sample code for creating a deadlock, but then Glenn Condron on the EF team suggested just throwing the error by leveraging the new EF6 ability to intercept commands & queries headed to the database. It can also intercept data coming back.

A few people have asked how I did this, so I’ll share my setup here.

I played with that a bit and realized that the SqlAzureExecutionStrategy required more than just the correct error code to trigger the retries. It needs a SQLException to throw that error. And a little more banging led me to realize that you can’t just instantiate a SqlException, it has to be done via reflection.

But I don’t give up easily. I found some helpful examples for doing this though it still wasn’t simple. Maybe things have changed, but I finally tweaked teh sample code enough to get what I needed.

Still, I was unsuccessful because EF was first doing it’s initialization tasks and the SqlAzureExecutionStrategy was not responding to errors thrown by those commands. I had to filter those commands out. Then finally, it worked!

There may be an easier way. I know Glenn does this differently. What I have worked out is witnessing the retries but since that’s all I watned to see, I’m not worried about having one of those retries be successful. I know that in the real world, as it’s retrying and the transient connection kicks back in, one of those retries will get through.

So to test out the feature you need four puzzle pieces.

1) Intercept the (non initialization/migration) command

2) Use DbConfiguration to make sure the interception is happening

3) Use DbConfiguration to set up the SqlAzureExecutionStrategy

4) Run an integration test that will attempt one or more queries on the database via EF.

Step 1) Intercept the command and throw the correct error

For this I created a new class, TransientFailureCausingCommandInterceptor, that inherits from IDbCommandInterceptor. There are a number of methods to override. The only one I’m interested in is ReaderExecuting…i.e. a read command is about to execute.

 public class TransientFailureCausingCommandInterceptor : IDbCommandInterceptor
 {
    public void ReaderExecuting(
      DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
    {
    }
    etc…

In the command , I filter out commands that are for the database initialization and migration work, in case they are executing.

For any other commands, I write out some info to Debug so I know that a query is about to execute, then I use my helper class to create a fake SQL Exception that throws one of the transient error codes that SqlAzureExecutionStrategy looks for: 10053.

  public void ReaderExecuting(
      DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
    {
      if (!(command.CommandText.Contains("serverproperty") 
        || command.CommandText.Contains("_MigrationHistory")))
      {
        Debug.WriteLine("throwing fake exception from interceptor");
        throw SqlExceptionFaker.Error10053;

      }
    }

The SqlExceptionFaker is the magic for throwing a SqlException. It is a twist on  this example I found from Microsoft MVP, Chris Pietschmann. I found some other ways of doing this but , in my opinion, Chris’ was the best of the solutions that I found.

using System.Collections;
using System.Data.SqlClient;
using System.Runtime.Serialization;

namespace SqlExceptions
{
  public static class SqlExceptionFaker
  {
    private static SqlException _error10053;

    public static SqlException Error10053
    {
      get
      {
        if (_error10053 == null)
        {
          _error10053 = Generate(SqlExceptionNumber.TransportLevelReceiving);
        }
        return _error10053;
      }

    }
    public enum SqlExceptionNumber : int
    {
      TimeoutExpired = -2,
      EncryptionNotSupported = 20, 
      LoginError = 64,
      ConnectionInitialization = 233,
      TransportLevelReceiving = 10053,
      TransportLevelSending = 10054, 
      EstablishingConnection = 10060,
      ProcessingRequest = 40143, 
      ServiceBusy = 40501, 
      DatabaseOrServerNotAvailable = 40613
    }

    public static SqlException Generate(SqlExceptionNumber errorNumber)
    {
      return SqlExceptionFaker.Generate((int) errorNumber);
    }

    public static SqlException Generate(int errorNumber)
    {
      var ex = (SqlException) FormatterServices.GetUninitializedObject(typeof (SqlException));

      var errors = GenerateSqlErrorCollection(errorNumber);
      SetPrivateFieldValue(ex, "_errors", errors);
      return ex;
    }

    private static SqlErrorCollection GenerateSqlErrorCollection(int errorNumber)
    {
      var t = typeof (SqlErrorCollection);
      var col = (SqlErrorCollection) FormatterServices.GetUninitializedObject(t);
      SetPrivateFieldValue(col, "errors", new ArrayList());
      var sqlError = GenerateSqlError(errorNumber);
      var method = t.GetMethod(
        "Add",
        System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance );
      method.Invoke(col, new object[] {sqlError});
      return col;
    }

    private static SqlError GenerateSqlError(int errorNumber)
    {
      var sqlError = (SqlError) FormatterServices.GetUninitializedObject(typeof (SqlError));

      SetPrivateFieldValue(sqlError, "number", errorNumber);
      SetPrivateFieldValue(sqlError, "message", errorNumber.ToString());
      SetPrivateFieldValue(sqlError, "procedure", string.Empty);
      SetPrivateFieldValue(sqlError, "server", string.Empty);
      SetPrivateFieldValue(sqlError, "source", string.Empty);
      SetPrivateFieldValue(sqlError, "win32ErrorCode", errorNumber);

      return sqlError;
    }

    private static void SetPrivateFieldValue(object obj, string field, object val)
    {
      var member = obj.GetType().GetField(
        field,
        System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance
        );
      member.SetValue(obj, val);
    }
  }
}

Phew!

Step 2) Force the context to use this interceptor

This happens in the lovely new DbConfiguration class. Read more about it here.

public class CustomDbConfiguration : DbConfiguration
{
  public CustomDbConfiguration()
  {
   AddInterceptor(new CasinoModel.TransientFailureCausingCommandInterceptor());
   }
}

Step 3) Make sure your DbConfiguraiton class is wired up in app/web.config in the EntityConnection section:

 <entityFramework codeConfigurationType="DataLayer.DbConfigurations.CustomDbConfiguration,CasinoModel">
  . . .
 </entityFramework>

 

Step 4) Test

This is a test that works with my model. Notice that my test specifies a connection string. That ensures that my context is using the SQL Azure connection I set up in my config file.

   [TestMethod, TestCategory("Connection Resiliency")]
    public void CanHitSqlAzureDbWithTransientFailure()
    {
      int slotcount = 0;
      using (var context = new CasinoSlotsModel(connectionStringName: "CasinoHotelsAzure"))
      {
        foreach (var casino in context.Casinos)
        {
          context.Entry(casino).Collection(c => c.SlotMachines).Load();
          slotcount += casino.SlotMachines.Count;
        }
      }
      Assert.AreNotEqual(0, slotcount);
    }

The test fails because an exception was thrown – the SqlException that I faked. That’s because an error is getting thrown. When I check the output

The SqlException caused a series of exceptions in response. Notice the nice message from EntityException: “consider using a SqlAzureExecutionStrategy”.

Result Message:
Test method AutomatedTests.UnitTest1.CanHitSqlAzureDbWithTransientFailure threw exception:

System.Data.DataException: An exception occurred while initializing the database. See the InnerException for details. —> System.Data.Entity.Core.EntityException: An exception has been raised that is likely due to a transient failure. If you are connecting to a SQL Azure database consider using SqlAzureExecutionStrategy. —>

System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. —>

System.Data.SqlClient.SqlException: Exception of type ‘System.Data.SqlClient.SqlException’ was thrown.

Looking at the failed test’s OUTPUT I see the text spit out by the ReaderExecuting method:

image

The method was only hit once, so I see my message only once.

Step 5) Add in the SqlAzureConnectionStretegy to the DbConfiguration file:

 public CustomDbConfiguration()
  {

    AddInterceptor(new CasinoModel.TransientFailureCausingCommandInterceptor());
    SetExecutionStrategy
      (SqlProviderServices.ProviderInvariantName, () => new SqlAzureExecutionStrategy());
   }

Using the default settings of SqlAzureExecutionStrategy will cause 5 retries.

Step 6) Run the test again:

The test hangs for a lot longer than fails. Why longer? The retries! I get 6 messages. The first is the initial problem and the other 5 are for each of the 5 retries.

image

Why does it still fail? Because my setup doesn’t “turn off” the error. That’s fine. I just want to see that it does actually retry.

The exception is different this time. RetryLimitExceededException, max retries (5) , etc…

Result Message:
Test method AutomatedTests.UnitTest1.CanHitSqlAzureDbWithTransientFailure threw exception:

System.Data.DataException: An exception occurred while initializing the database. See the InnerException for details. —> System.Data.Entity.Infrastructure.RetryLimitExceededException: Maximum number of retries (5) exceeded while executing database operations with ‘SqlAzureExecutionStrategy’. See inner exception for the most recent failure. —>

System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. —>

System.Data.SqlClient.SqlException: Exception of type ‘System.Data.SqlClient.SqlException’ was thrown.

Step 7) Modify the connection retries

Next I’ll change the default of the SqlAzureExecutionStrategy to retry only 3 times.

(SqlProviderServices.ProviderInvariantName, () => new SqlAzureExecutionStrategy(3,new TimeSpan(15)));

Look at the output after I run the test again. Only 3 retries then it gives up.

image
So that’s it. I’m content to see this feature in action.

I was also happy to see a comment in the previous blog post from a developer who has seen the benefits of this feature already in their production environment.

EF6 Connection Resiliency for SQL Azure* – When does it actually do it’s thing?

*Windows Azure SQL Database makes the blog post title just too darned long!

Followup post: Testing out EF6 Connection Resiliency

I’ve been messing around with the DbExecutionStrategy types in EF6 and trying to force the strategy to kick in.

I spent a horrid amount of time going down the wrong path so thought I would elaborate on the one I’ve been banging on: SqlAzureExecutionStrategy.

I thought that by disconnecting my network connection at the right moment I would be able to see this work. But it turned out that my results were no different in EF5 or with EF6 using it’s DefaulSqlExecutionStrategy (which does not retry).

I finally looked yet again at the description and at some older articles on connection retries for SQL Azure and finally honed in on a critical phrase:

transient failure

A transient failure is one that will most likely correct itself pretty quickly.

Looking at the code for the SqlAzureExecutionStrategy,  you can see the following comment:

/// This execution strategy will retry the operation on <see cref="T:System.TimeoutException"/> 
/// and <see cref="T:System.Data.SqlClient.SqlException"/>
/// if the <see cref="P:System.Data.SqlClient.SqlException.Errors"/> contains any of the following error numbers:
/// 40613, 40501, 40197, 10929, 10928, 10060, 10054, 10053, 233, 64 and 20

Focusing on these errors led me to a number of articles aimed at dealing with this same list of transient failure.

Here is a code sample from the Windows Server AppFabric Customer Advisory Team that contains brief descriptions of the errors:

// SQL Error Code: 40197
// The service has encountered an error processing your request. Please try again.
case 40197:
// SQL Error Code: 40501
// The service is currently busy. Retry the request after 10 seconds.
case 40501:
// SQL Error Code: 10053
// A transport-level error has occurred when receiving results from the server.
// An established connection was aborted by the software in your host machine.
case 10053:
// SQL Error Code: 10054
// A transport-level error has occurred when sending the request to the server.
// (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
case 10054:
// SQL Error Code: 10060
// A network-related or instance-specific error occurred while establishing a connection to SQL Server.
// The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server
// is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed
// because the connected party did not properly respond after a period of time, or established connection failed
// because connected host has failed to respond.)"}
case 10060:
// SQL Error Code: 40613
// Database XXXX on server YYYY is not currently available. Please retry the connection later. If the problem persists, contact customer
// support, and provide them the session tracing ID of ZZZZZ.
case 40613:
// SQL Error Code: 40143
// The service has encountered an error processing your request. Please try again.
case 40143:
// SQL Error Code: 233
// The client was unable to establish a connection because of an error during connection initialization process before login.
// Possible causes include the following: the client tried to connect to an unsupported version of SQL Server; the server was too busy
// to accept new connections; or there was a resource limitation (insufficient memory or maximum allowed connections) on the server.
// (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
case 233:
// SQL Error Code: 64
// A connection was successfully established with the server, but then an error occurred during the login process.
// (provider: TCP Provider, error: 0 - The specified network name is no longer available.)
case 64:
// DBNETLIB Error Code: 20
// The instance of SQL Server you attempted to connect to does not support encryption.
case (int)ProcessNetLibErrorCode.EncryptionNotSupported:
  return true;

A TechNet wiki article on handling transient failures from Windows Azure SQL Database, warns:

One thing that’s tricky about retry logic is actually inducing a transient error for testing.

Oh, now they tell me! (I am a pitbull and tried so many things already).

Their solution is to intentionally cause a deadlock.

So the SqlAzureExecutionStrategy builds in the same retry logic that until now we’ve had to hand code (ala the example in the TechNet article or the Customer Advisory Team code sample.

I have no question that it will work. I just really like to demonstrate before and after when I can rather than just regurgitate what I’ve read somewhere. 🙂

Followup post: Testing out EF6 Connection Resiliency

The somewhat super secret MSDN docs on EF6

Along with all of the great info on entityframework.codeplex.com, the MSDN Library has a bunch of documents targeting EF6, currently listed as “Future Version”. There is a “Future Version of EF” page but it doesn’t have links to these articles. And I’ve found some of these to be more current than their related specs on Codeplex.

I’ve only ever found them accidentally via GoogleBing or when bugging someone on the EF team and they send me a link. Since I haven’t found a single location with these links, I am really just selfishly creating this list for myself.

Keep in mind that I may have missed some!

Coding for Domain-Driven Design: Tips for Data-Focused Devs

In honor of the 10th Anniversay of Eric Evan’s book: Domain Driven Design, Tackling Complexity in the Heart of Software (Addison-Wesley Professional, 2003), I’ve written a 3-part series for my MSDN Data Points column.

August 2013: Data Points: Coding for Domain-Driven Design: Tips for Data-Focused Devs

Domain Driven Design can help handle complex behaviors when building software. But for data-driven devs, the change in perspective isn’t always easy. Julie Lerman shares some pointers that helped her get comfortable with DDD.

September 2013:Data Points: Coding for Domain-Driven Design: Tips for Data-Focused Devs, Part 2

In the second column in her series on Domain Driven Design, Julie Lerman shares more tips for data-first developers who are interested in benefiting from some of the coding patterns of DDD.

October 2013: Data Points: Coding for Domain-Driven Design: Tips for Data-Focused Devs, Part 3

Julie Lerman explores two important technical patterns of Domain Driven Design (DDD) coding–unidirectional relationships and the importance of balancing tasks between an aggregate root and a repository–and how they apply to the Object Relational Mapper (ORM), Entity Framework.

My Long-Running, Not-Yet-Complete, Investigation into a New Haswell Ultrabook

(I’m updating this post frequently as I learn more about these machines or about ones I haven’t looked at well enough yet)

Dec 18 update:

The search is over! I’m in Love!

Well, the Samsung Ativ Book 9 Plus  (8GB RAM, 256GB SSD) arrived late one night last week. The poor Fedex driver showed up at my house at 9pm and still had 15 deliveries to go after mine. I gave him a piece of home-made apple pie for the rest of his journey. I’ve now had the Samsung for 5 days and yesterday I cancelled the not-yet-shipped-after 4 weeks Dell XPS13. I was already in love with the Samsung so there seems to be no point in doing a comparison.

It’s light (3 pounds), quiet (unless I’m stressing it out), much faster than my Thinkpad (I did some geekbench comparisons) and I just love looking at the battery status and seeing “5 hours left” “7 hours left”. I love the keyboard and after struggling with the thinkpad’s eraser mouse and touchpad for so many years, I took to the Samsung’s touchpad “like a duck to water”. I had to do a bit of finagling to get my RDP setup to handle its super duper high res but am now using it as my full time machine with the ehinkpad nearby in case I forgot to install or copy anything.

I will definitely write a blog post at some point.

Amazon now has these available now on a pretty steady basis.

Dec 4 update:

Dell started selling the XPS13 a few days after my last update so I ordered that although it wouldn’t be shipping for over 4 weeks from when I ordered! Then Samsung’s shipping time went down to 1-3 days so I called to order one on Nov 20th. But I was told that the pre-orders were going out and they wouldn’t be able to ship one to me until Dec 13. I went ahead and placed the order. Was frustrated to see them shipping on Amazon with no wait about a week later but such is life. But I was excited a few days later to get an email that it shipped. The box arrived today. It was suspiciously light…much less than 3 pounds. All they had shipped was the free laptop sleeve that is part of their p.r. I have no idea when I’ll get either laptop and it’s driving me batty (blame A.D.D.). When I ordered the Dell, they had a promo for free shipping, free returns and no restocking. This means I get to try it out and if it’s not the one, it won’t have cost me anything (money, that is). Samsung was close with free shipping and no re-stocking fee. It is the only way I can get a hands-on look at these since they are definitely not available in our local Best Buy or Staples. And they won’t be for a while. We are a minor market. I couldn’t even find the 4GB/128SSD version of the Ativ at our BestBuy. So the wait continues. I’m guessing the Samsung will be the winner. Getting it to me weeks before the Dell would have helped dramatically because I would have grown fond of it by then. In the meantime, I have some friends who grabbed the Ativ on Amazon and are loving it. Today, it looks like the window of Amazon having those on hand is gone. Better wait in line behind me! 🙂

November 16 update:

Samsung ATIV Pro book 9 is announced but not on amazon anymore and not shipping from Samsung for at least a month. Dell XPS 13 is now orderable from their website but not shipping for another month. I have reconsidered MacBook Air but I really really really want touch! I have looked more closely at the Yoga Pro 2 but am reading enough negative stuff about it that it’s still a no (and I’m a long time thinkpad tablet /laptop user). I have reconsidered the Acer S7 but still want FKeys (even though other dev friends are okay with it). I have checked back with Toshiba Kira but they seem to be clueless about the reported fan noise complaints. I got hands on with the Surface Pro 2 but decided that I can’t use Visual Studio on that tiny screen when I’m presenting at conferences etc. I do want to do this before the end of the year (think: taxes). I thought I would pre-order the XPS13 and just return it if I don’t like it (current promo says no restocking fee) but the chat support was unable to 100% confirm key info about order/invoice/shipping dates that would affect this promo and I remembered that I don’t want to depend on Dell support anyway). I’ve re-checked other options (e.g. Asus, Sony) and still don’t want them. I’ve learned that there are issues with Windows 8 and the new fancy hi res screens but expect them to get resolved. I have had a thousand repeated recommendations on twitter from kind people who don’t realize I’ve spent about 40 hours obsessing over this already and have considered everything they are suggesting already. So I’m going to try to set it aside and wait a little longer. Today’s thought is that the Samsung will win. But I’m fickle and a crazy Libra so we’ll just have to see…)

Anyone who follows me on twitter may be familiar with my ridiculous, drawn out, indecisive process when i have to buy new gear. It’s time for a new laptop. I’ve been thinking about it for months. Because of this I have the added problem of forgetting what I liked or didn’t like about certain machines.

Here’s what I know I want:

  • Intel Haswell chip for long battery..most likely i7, but i5 could suffice
  • Light! I am hoping for under 3 pounds.
  • Min 8GB RAM
  • Min 256 GB Drive
  • Quiet because even though I record my Pluralsight & other videos on my desktop, I need to have my laptop running at the same time.
  • In my hands and ready to head off to conferences with me at the end of this month!

I do production code and video recording and run VMs on my desktop. Everything else on my laptop including pick it up and go when I travel. So I don’t need quad core heavy duty on the laptop.

What I’ve looked at seriously:

 

Acer Aspire S7-392-9890 13.3-Inch Touchscreen Ultrabook

This is under 3 pounds. It claims a 7 hr battery life. According to a number of friends, the previous version (Ivy Bridge) has a lot of fan noise. Perhaps the Haswell version is quieter, but there is a possible showstopper for me: no F keys. The number keys serve as number and FKeys meaning that you have to do learn new key combos to Run or Debug an app in Visual Studio etc etc. Or to use Zoomit. I just don’t know if I want to make that commitment.

Showstopper: No F Keys

 

Toshiba KIRAbook 13 i7 Touchscreen Laptop

Cori Drew loves hers even though she threw it across the room (accidentally as she was wandering around looking for wifi because hers has a faulty wifi card or something like that). But, it’s got amazing resolution – to compete with Mac’s Retina display, is very light, very high end and very well built. Plus she says the customer service is fantastic. But….here we go again….the fan is crazy noisy. Crazy noisy like in a room full of developers, all eyes will suddently be on her becaus eof the fan. Many reviews complain about this as well. This just won’t work for recording.

Showstopper: Head turning fan noise

 

Samsung ATIV Book 9 NP900X3E-K01US 13.3-Inch Full HD Premium Ultrabook

Everything I’m looking for and 2.6 pounds, but this excellent Engadget review mentions the fan noise:

The ATIV Book 9 Plus pipes up quickly — heck, it sometimes makes noise when it’s sitting idle. But that noise never rises above a quiet sigh. In fact, we didn’t even notice it until we paused Pandora and started to work without any background noise.

“Quiet sigh”….I have worked hard to reduce the noise in my office for recording. I don’t know how loud a quiet sigh is but since it’s loud enough to write a whole paragraph about, I’m guessing louder than I want.

Showstopper: Fan noise?  SCREECH: wait, forget the fan noise, only 4GB RAM Max??  128GB drive? Not upgradable? Pfft!

 

The 8GB/256SSD is now listed on Samsung’s site:http://www.samsung.com/us/computer/pcs/NP940X3G-K04US  You can pre-order but it says “ships in 3-4 weeks” (I’m writing this on Nov 16)

Amazon has a place h older page but it’s not yet orderable: http://www.amazon.com/Samsung-NP940X3G-K04US-13-3-Inch-Laptop-Mineral/dp/B00F6EOB8C

Apple MacBook Air MD760LL/A 13.3-Inch Laptop (NEWEST VERSION)

Yes, a macbook! Many friends use MacBook Pro with Windows & Visual Studio development. But the 2013 MbA has a haswell chip and can come configured with 8GB RAM and up to a 512GB drive. It doesn’t have the Retina display but that was one of those features I didn’t know I needed. It’s under 3 pounds. I could get a Pro with Retina display for another 1/2 lb but a quad core mac book pro is a 4.5 lb 15” computer. That’s about what I have now (though obviously much nicer, longer battery life and more powerful). But size matters, too! 🙂

Cons are no touch screen. I use my touch screen a lot on my laptop. I would miss it madly.

I’m going to be near the local Apple reseller today and will try them out. I’m hoping they’ll have Airs and Pros with Win8 installed on them.

Dell XPS 12 Convertible Ultrabook

I’d ignored this because it’s weird looking but that’s silly.Very high end, great graphics, 8+ hrs of battery.

It’s also 3.35 pounds, which I know is negligible and still a lot less than the 4.75 lbs of my thinkpad when I have the extra battery in it (which is always when I’m travelling)

Sony VAIO Pro SVP13215PXB 13.3-Inch Core i7 Touchscreen Ultrabook

Forgot that I had looked into this , perfect in every way but:

showstopper: fan noise (http://forum.notebookreview.com/sony-owners-lounge-forum/720737-official-vaio-pro-13-owners-lounge-svp13-2013-a-88.html) & http://forum.notebookreview.com/sony/726097-sony-vaio-pro-13-fan-noise-return.html

🙁

ThinkPad X1 Carbon Touch

(I can hear Scott Hanselman now, “’all that research and you missed my blog post review?”.

“starting at 3.4 lbs” so I wasn’t really looking at it. Plus in the comments of Scott’s post, another owner says “One other thing that really bothers me is that the fan is running at a quite noisy level – constantly”. 🙁

Currently they are built with 3rd generation chips. Looks like Haswell machines won’t be out until January 2014.

Am I asking too much?

Am I being too much of a stickler about the noise? Head-turning loud (Kirabook) is really impossible for me for recording. Maybe the Samsung Kiva’s “quite sigh” is not going to be a bad thing after all. I just need some more feedback on that. I just don’t want to buy something, make the effort of setting it up and then decided I don’t like it.

Coming soon but not soon enough for my pre-conference hopeful deadline:

Not to be overlooked is the new Surface 2 Pro. It will also be light, fast, long battery life, touch screen etc. But I really wanted to have something before I head off to conferences at the end of this month so that’s not doable unless I keep waiting and lug my thinkpad around for more trips. And I want to hear what my friends say about it before I buy one.

Dell: Precision M3800 workstation: 4.5 lbs …NOPE

Dell XPS 13 Ultrabook  about 3 lbs, but still “coming soon…”

Availability and Pricing  (source Oct 2 press release)
The Dell Venue 7, Venue 8, Venue 8 Pro, and new XPS 15 will be available from October 18 on www.dell.com in the United States and select countries around the world. The Venue 11 Pro, XPS 11 and the updated XPS 13 with touch will be available in November. Starting prices are as follows:

  • New XPS 15: $1,499.99
  • XPS 11: $999.99
  • New XPS 13: $999.99

What’s that Read_Committed_Snapshot Transaction Support for EF6 About Anyway?

One of the items listed in the EF6 specs is:

  • Default transaction isolation level is changed to READ_COMMITTED_SNAPSHOT for databases created using Code First, potentially allowing for more scalability and fewer deadlocks.

 

I’m no database wizard, so I have mostly just glazed over that. It’s one of those changes that most devs take for granted…some default setting changed, it’s a better default…okay, thanks… But I’m a bit of a plumber and don’t like to take much for granted. I wanted to see a before and after.

In all honesty, I initially misread this. If I did,I’m sure a few others have as well. I didn’t even know what this transaction level was…but I only know enough to be dangerous about database transaction levels anyway.

So I started by looking to see if EF6 was setting this transaction level in it’s internal code when it created connections to do queries or other commands.

WRONG!

I read more closely and started looking for the database creation code in EF, thinking that it sets this transaction level in order to execute the various commands to create the database and schema.

WRONG AGAIN! 🙂

So I started looking into dbtransactions and there is no such isolation level!

Here’s the documentation:

image

Where is READ COMMITTED SNAPSHOT?

Not there because I was WRONG AGAIN! 🙂

Finally I started noticing that READ_COMMITTED_SNAPSHOT is a SQL Server database setting, not an on the fly setting for a specific transaction. It is an ON/OFF switch. Your database either uses a snapshot or it does not. (Please let me know if I’m wrong about it being SQL Server only. It’s all I’m able to find.)

So it’s a parameter that needs to be set when creating a database. AHA! Up through EF5, EF was ignoring that setting when creating a database. But it turns out that it’s something of a “best practice” to have that setting ON.

What does it mean to have READ_COMMITTED_SNAPSHOT ON for SQL Server database?

Nick Beradi provides a nice explanation in his blog post, Deadlocked!: “read committed snapshot” Explained.

Basically what this does is create a snapshot or read-only database of your current results that is separate from your live database. So when you run a SELECT statement, to read your data, you are reading from a read-only copy of your database. When you change your database, it happens on the live database, and then a new copy or snapshot is created for reading against.

So now, as a plumber, I know how to show before and after. 🙂

Here I’m asking SQL Server what the setting is for my database named EFDataLayer.ThingieContext which was created by EF5:

image

The value is 0. Read_Committed_Snapshot is OFF.

Here’s another one, but this one was created by EF6:

image

The value is 1. Read_Committed_Snapshot is ON.

That’s the change. Most of us will never even notice it. But it will alleviate problems like this one, one of many in stackoverflow (and disregard the response, which is not marked as an answer for a reason 😉 ) http://stackoverflow.com/questions/17529064/using-read-committed-snapshot-with-ef-code-first-5

But I Don’t Want That ON by Default

You can always go to the database and call

ALTER DATABASE MyDatabase
SET READ_COMMITTED_SNAPSHOT OFF

I Just Want to Use Snapshot On-Demand

That’s what the transaction level support is for.

You can always create your own transaction and set the isolation level to SNAPSHOT for specific command execution.

Next Steps?

You have now reached the limit of my Snapshot “expertise”. For more, check out the MSDN doc on Snapshot Isolation in SQL Server or try googlebing or maybe this (#itsATrap!).