All posts by Julie

Fall conferences: DevIntersection and OreDev

Finally the spring conference season is behind me. Yes, it lasted until July 13th! (I don’t like to leave Vermont in the summer so I lumped the last bunch of commitments – DDDSummit, TechEd North America, TechEd Europe and CodeStock) into my “spring travel” plans.

The next conferences I’ll be speaking at are in the late fall.

 

DevIntersection

http://devintersection.com/

October 27-31 at MGM Grand in Las Vegas

DevIntersection is 5 conferences in one: Visual Studio, SQL, ASP.NET, Sharepoint and WIndows Azure

It is also co-located with the <anglebrackets> conference (http://anglebrackets.org/)

You can use my last name (LERMAN) for a discount when registering. Each speaker has a discount code and we are in *competition* for who gets the most registrations using their code. And yes of course, the winner is rewarded – Vegas style! 🙂 So consider the gauntlet thrown. 🙂

I’ll be presenting 3 talks:

VS17: A Practical Look at Entity Framework in Domain Driven Architecture

Considering how your data will get persisted is not a concern with Domain Driven Design (DDD), but at some point you will have to persist your data somewhere, somehow. This session is for developers who use Entity Framework and want to know how some of the key DDD concepts such as aggregate roots, bounded contexts and value objects work out when it’s time to add in your data layer. We’ll talk about some of the struggles you may go through trying to change your perspective from data first to domain first from someone who has experienced this brain shift first hand.

VS15: Entity Framework 6 – Ninja Edition

Entity Framework 6, the first iteration of EF as an open-source project, is no longer just a pretty little unicorn. EF6 addresses many of the productivity issues that developers have requested to really make it shine as an ORM. While there are a number of new features that will be core to any EF development – such as async support, stored procedure support for code first, improved warm-up time – many of the new features are for developers who fall in the "ninja" category. In this session we’ll run through many of these features like the return of custom code first conventions, query interception and SQL logging, connection resiliency, transaction improvements and more.

VS18: Entity Framework in the Enterprise

Demoware is great for getting your head around a new topic but we’ve been seeing Entity Framework demoware for 5 years now. You’re probably not writing an application to manage your music collection or composing yet another Twitter client. You build big applications for your businesses and you need to know how to integrate Entity Framework in serious architectures. In this session, we’ll look at breaking up your models following the Domain Driven Design Bounded Context pattern, designing repositories and units of work that are relevant to EF DbContext and DbSets. You’ll also see how to build automated tests around code that involves Entity Framework, whether they be integration tests or strictly unit tests where Entity Framework seems to get in the way.

 

Øredev 2013

http://oredev.org/2013

November 4-8

Malmo, Sweden

I’ll be presenting one session:

Entity Framework in Core-Business Applications that Leverage DDD

In this session we’ll look at breaking up your domain-models following the Domain Driven Design Bounded-Context pattern, splitting and defining entities and aggregates properly in the different domain models and implementing repositories and units of work that are relevant to EF DbContext and DbSets, in the data persistence infrastructure layer.

CodeStock 2013: Wow

I’m just home from attending & speaking at CodeStock 2013 in Knoxville, TN.

I’ve always heard what a great conference it is…though most of the legends were around parties at Alan Stevens’ house! After CodeStock 2012, Alan pinged me and asked me to give the keynote for the next one. I’m reluctant to leave home in the summer and …haha right….me giving a keynote! But when Alan said his idea was for me to talk not about a technology but about some of my experiences as a developer of nearly 25 years. I think at the time he had in mind something about how I had made my recent journey into Domain Driven Development. Though over year since then and with encouragement from Nathan Blevins and conversations with many, I evolved this into a talk which I titled “Disrupt Your Comfort Zone”.

When the call for abstracts was announced, I decided not to rest on my keynote laurels and submitted two abstracts on some topics I am currently passionate about sharing: one is a talk about where Entity Framework and DDD intersect (a talk that has been evolving over time from my EF in the Enterprise session) and the other is a short version of my Automated Testing for Fraidy Cats Like Me course on Pluralsight.  The intention behind the keynote and both talks was to help alleviate fear & trepidation many of us developers have about learning new, possibly daunting (ala TDD) and possibly huge (ala DDD) topics.

I was surprised that both of my session submissions were accepted. I was going to be a busy girl.

Alan, Nathan and the other organizers (Andrew May and Don Den Uyl (sounds like" “denial” 🙂 )) were very generous with their time and energy and support. I was pretty nervous about the keynote. I wanted it to be great and I wanted them to be happy they had asked me to do it and I wanted attendees to walk away inspired and feeling great about themselves. (yes a tall order, but …. “go big or go home”). I even spent time with the wonderful Deborah Hartmann Preuss who is an agile coach and a life coach who helped me deal with the vast amount of ideas I had spinning around my head and figure out how to find a thread… a path through this talk.

Alan and his fantabulous wife, Michele, let me stay at their house. (Please don’t tell Sampson about my new-found love for their dog, Malcom!) Rachel Reese was there too (just from LambdaJam and doing a well-received F# talk) and (I’m laughing) she had driven down from Chicago (don’t ask) so I managed to get carted around the whole time by one friend or another.

I *think* the keynote went well (if you thought it sucked and don’t want to look like a jerk for saying so, feel free to contact me privately). Just having a handful of people tell me afterwards (& on twitter) that they were inspired, and learning that I also am most always overwhelmed by the challenges of learning made them feel better (ala “I am not alone”) was enough to make me ecstatic. I don’t imagine I was able to do that for everyone in the room, but knowing that I was able to give something useful to those who I heard from makes me a little verklempt.

The keynote began with this video:

And ended with this image:

Silhouette of hiker against mountain backdrop (Tennessee Department Of Tourist Development)

It also included bird-murdering cats.

I also truly enjoyed giving my other talks. The first was in a very small room with people standing in the hallway…others giving up and going off to other talks. I loved that on twitter, there was an impression of a standing-room only, overflowing attendance. But the truth is that there were only 22 chairs in the room and maybe 35 people were able to squeeze in. It wasn’t that hundreds were trying to attend. 😉

That session, the keynote and the Women in IT panel were all on Friday. The WIT panel was co-organized by the amazing gals, Corinna Brock and Arlene Gray (best twitter handle ever: @WhimSQL). The three of us made up the panel. And OMG! It turns out that Corinna was a 2003 grad of the same VERY SMALL very special liberal arts college (Wells College) that I graduated from (so many years ago that I’m not even going to put that down).

That night I managed to lose my laptop. (In the end, it turned out that I had left it behind in the vendor area when Rachel (it’s her fault, I swear) called to me from the elevator to hurry up (her fault! her fault!)). I didn’t notice how light my bag was until 1 restaurant, 1 ice cream parlor, 1 after party and then all the way back to Alan’s house. I chose not to freak out (thank you crashplan) and was only worried about how I was going to prepare for my Testing for Fraidy Cats talk the next day. So yeah, I got there early on Saturday and got my laptop and hid out to prepare for a few hours.

In the afternoon, I left the conference to go take a quick peek at the Smoky Mountains with Srinu Tulluri and fellow Pluralsight author, Michael Perry. Then we dropped Michael at the airport and I got his rental car since I was staying for another 24 hours.

I had another wonderful night at Alan & Michele’s. I watched a movie with Michele and their son while Alan, Chapman Smith, Srinu and Spede Bryan, spouted off  and had a grand old time (with the help of a bottle of bourbon) on the porch. 🙂

As if this wasn’t already a wonderful weekend, the next day was even more beautiful for me. After pancakes and another git lesson, I drove out to Oak Ridge to visit my 96 year old Great Aunt and Uncle. (He’s a real character with an incredible history and was featured recently on the local t.v. station). I haven’t seen them in too many years. I cried when I arrived. I cried when I left. I captured lots of video and family stories to share with the rest of my family. So thank you thank you, CodeStock, for this gift. Notice that my 96 year old Auntie’s hair isn’t even white. It’s still got a lot of brunette in it. Darn…I don’t have those genes. However, Uncle Josh has a full head of hair at 96 and on my father’s side, his dad had a full head of hair still in his late 80’s when he passed away. Of course there are more important things that I have acquired from them genetically, but still… And Aunt Grace got a huge kick out of my green fingernail and toenail polish.

WP_20130715 2

EF6 Beta 1 Tools First Pass is VS EF Designer, Not Power Tools, Yet & I’m Good With That

With EF6, Microsoft (and the community that is helping with this OSS project) is pulling the Entity Framework Designer tools out of the Visual Studio install and making them a part of EF6. While you can add EF6 into a project via NuGet, tooling is a different story. That gets installed via an MSI (maybe eventually via Extensions in visual studio gallery?).

The recent blog post that announced the availability of EF6 Beta 1 and the first pass at the out of band tooling [EF6 Beta 1 Available] said :

  • The EF tooling is included in this preview for the first time for the EF6 release. Our focus with the tooling has been on enabling EF6 support and enabling us to easily ship out-of-band between releases of Visual Studio. The tooling does not included any new features.

My assumption from reading “The tooling does not included any new features” is that what’s in this MSI will only replace the built in VS designer.

Don’t forget that we also have the Entity Framework Power Tools. I recently wrote about my favorite feature of the Power Tools here:

Entity Framework Power Tool Tips to View Model (A Feature I Depend On!). The plan is to incorporate them into the designer so that there is one consolidated tool.

Based on the blog post, I didn’t expect to see any of the Power Tool features in the EF6 Beta 1 Tools.

But someone asked about one of the power tool features on twitter, and even though my confidence was high, I didn’t want to reply with “well I’m pretty sure that the blog post means no”, so I spun up a new virtual machine with VS2012 and installed the new tools.

And as the blog post says: no new features. In other words, the Beta1 is just the same designer that is in Visual Studio.

image

They have so far performed that task of separating the designer and now they can start adding the new features which will be something like what they’ve laid out in the the Tooling Consolidation Feature Specs on codeplex.

My New Pluralsight Course: Automated Testing for Fraidy Cats Like Me

Pluralsight has just released my newest course: Automated Testing for Fraidy Cats Like Me

This is the 43 second introduction to my new course.

Watch the full course: Automated Testing for Fraidy Cats Like Me

It was also the 500th course to be added to their library, so a nice milestone to be associated with!

It’s a story I’ve been wanting to tell for a long time.

The course is only 90 minutes long. It is aimed at developers who have been thinking “I should learn about testing” but have the impression that it’s such a big investment that there’s no point unless you are able to go “all in” so to speak. I was of that mind for a long time. I’m finally benefitting from testing and I still have not gone all-in.

You don’t believe me? As a VB4/5/6 developer my “tests” were either done in the immediate window or just by running the app. I couldn’t test logic until I’d built a UI to execute it.

I have worked with numerous clients where we will build a small method and then the client says “okay let me add some buttons and text boxes to my form to see if that logic works”.

Yep, I’ve been there and done that.

I finally got to an AHA! moment where I saw that automating some of those tests was a huge win for me.

So my goal for the course is to help developers like me (whether you are new to development or have been programming for a long time, like I have) get to that AHA moment. At the same time, I provide a “lay of the land” so to speak. I show a little bit about using some of the most common techniques. I write and run some code (all in Visual Studio and .NET but this should be relevant to developers working with any technology). And I also provide an overview of some of the variety of techniques and tools available.

This is really designed to give developers enough of a look at testing to determine if it’s something they really *do* want to learn and then enough of the basics to allow them – you? – to dive in to the many other learning resources that exist for automated testing.

Watch the full course: Automated Testing for Fraidy Cats Like Me

Need a free Pluralsight trial so you can watch my courses? Send me an email through my contact form.

Entity Framework Power Tool Tips to View Model (A Feature I Depend On!)

When defining models with Entity Framework’s Code First and a DbContext class, I find the “View Model” feature of the Entity Framework Power Tool completely indispensable. Without it, I only *think* I know what I’ve told EF my model should be but I don’t really know how Code First will interpret the information I’ve provided (class structures, DbSets, configurations).

For example, I may have a set of classes but a DbContext that only specifies a single DbSet:

    public class CustomerServiceContext : DbContext
    {
        public DbSet<Customer> Customers { get; set; }
    }

But because of relationships from Customer to other types and their relationships to even other types, using it’s base rules (convention) Code First interprets your entire model as

image

Another common point of mapping confusion is with relationships. Being able to visualize how Code First interprets the model can show me where, for example, I’ve attempted to define a 1:1 relationship but in fact, I’ve defined a 1:0..1 which will really create problems down the road in my application.

I use the tool to show me where I haven’t configured things properly and fix my mappings (via convention or configurations) until the visual model aligns with my intention.

So I really can’t live without this tool and I show it to everyone I can.

Currently the tool is something you install as an extension to Visual Studio. It’s called Entity Framework Power Tools Beta 3 and it works even wtih the latest update to VS (Visual Studio 2012 Update 2).

While there are other features, with the tool installed, you can point to any class that inherits from DbContext, right click and see “Entity Framework” on the context menu. Select Entity Framework and you’ll see four options. My focus is on the first of these “View Entity Data Model (Read-only).

SNAGHTMLb0b6d0b

But half the time I show it, it doesn’t work and it’s always something I’ve done wrong and forgotten about.

Designer Problems != Modeling Problems

If there is a problem with your model, you’ll get a helpful error message in the output window. This is about what’s wrong with your mappings. One common one is you tried to create a one to one mapping but haven’t given code first enough detail (e.g. it needs to know which is the principal and which is the dependent).

The focus of this blog post however is problems I encounter with getting the tool to perform it’s task.

Most Common Reason that the Designer Fails: Can’t Find the Connection String

Even though the designer is not going to touch the database to generate the view, it still needs to have access to a connection string.

But when it can’t find it, it doesn’t always tell you that it can’t find the connection string.

Typically I get an error message that says: “sequence contains no matching element”.

Another is “Exception has been thrown by the target of an invocation”.

Designer Looks for  the Connection String in the Startup Project of a Solution

This is the A#1 reason that the designer won’t work. It’s a bit of a pain because you don’t really want to set things up for the designer, but for debug mode. It doesn’t matter if the startup project is executable. It just has to be some project with a config file and in the config file, valid connection information ( a connection string or connection info in the Entity Framework section) that EF will look for.

Designer Will Not Look Inside Solution or Project Folders

This is my A#2 reason the designer won’t work. I like to organize my solutions. I organize projects into solution folders and I organize code into project folders. If you config file is in a folder, the designer won’t find it.

My Typical Setup for Success

So I have a separate project in my solution that is NOT inside a folder just to help me use this critical designer tool. Thanks to Vaughn Vernon for helping me find a better name for the project than I had been using that makes it very clear that this has nothing to do with my application at all.

image

So when I need to view a model, as long as I remember to set that project as the startup project in my solution, the designer is able to do it’s job. Here is an example of using this for a context that doesn’t even inherit DbContext directly. It inherits from my own class “BaseContext” which inherits from DbContext. The designer is able show me the visual model even with this extra abstraction.

SNAGHTMLb07a092

 

Another Weird Error that Is Not About the Connection String: “A constructible type …”

Thanks to Ethan in comments for pointing out this one. I actually had it the day *before* I wrote this post and had forgotten (short term memory issues…old age…excuses excuses 🙂 ).

‘A constructible type deriving from DbContext could not be found in the selected file’.

This was misleading because like Ethan, the fact that I was deriving from BaseContext led me to believe that *this* was the cause for not being able to find the DbContext type. But changing CustomerServiceContext to inherit DbContext directly did not fix my problem.

I found this StackOverflow thread about this error message with a response from Brice Lambson of the EF team that suggested an Visual Studio extension was the issue. I had just added two extensions for spell checking my code and comments. One was HTML Spell Checker (from Microsoft), the other was Multi Language Spell Checker (also from someone at Microsoft). So I thought I would disable one at a time to see if one was the culprit. I happened to pick HTML Spell Checker to disable first and voila, the View Entity Data Model tool worked again (after a VS restart). Fortunately the second extension is the one I had really wanted anyway.  I believe that this problem will be resolved by the time we get the tools integration in EF6.

My Current Pluralsight Courses on Entity Framework

Pluralsight - Hardcore Developer Training

Course Released Hrs:Min
Entity Framework 4.0 By Example Aug 2010 2:19
Entity Framework and Data Models Nov 2010 1:32
Designer Supported EDM Customization Jan 2011 2:05
Querying the Entity Framework Feb 2011 1:23
Entity Framework 4.1 – Code First Jun 2011 1:59
Entity Framework 4.1 – DbContext Sep 2011 1:21
Data Layer Validation with EF 4.1+ Feb 2012 1:54
Entity Framework Code First Migrations  Mar 2012 1:10
Getting Started with Entity Framework 5 Mar 2013 4:23
Entity Framework in the Enterprise  Sep 2012 3:16

 

Need a free 30-day trial for Pluralsight to check out my courses? Send me a note on my contact form

CodeStock Keynote and Maybe Some Sessions, too

image I’m thrilled to have been invited to deliver the keynote talk at CodeStock 2013 in Knoxville this July. I’ll be talking about how Domain Driven Design (DDD) has inspired me a-new after almost 25 years of software development. And I hope to inspire others to take a closer look at DDD as well.

In addition to the keynote, I submitted two conference sessions and sessions are selected by a voting process where registered attendees vote for the talks they want to hear. Such a cool idea.

I feel a little guilty submitting sessions since I already will be presenting the keynote and there are so many awesome abstracts including some on EF and DDD.

Here are the two talks I submitted if you’re planning to attend CodeStock and interested in hearing me go on about them. But if that’s the case, you’ll need to go vote.

 

Entity Framework in Core-Business Applications

Demo-ware is great for getting your head around a new topic but we’ve been seeing Entity Framework demo ware for 5 years now. You’re probably not writing an application to manage your music collection or composing yet another Twitter client. You need to build complex applications related to the Core-Domain in the enterprise and therefore you need to know how to integrate Entity Framework in serious and decoupled architectures. In this session we’ll look at breaking up your domain-models following the Domain Driven Design Bounded-Context pattern, splitting and defining entities and aggregates properly in the different domain models and implementing repositories and units of work that are relevant to EF DbContext and DbSets, in the data persistence infrastructure layer. You’ll also see how to build automated tests around code that involves Entity Framework, whether they be integration tests or strictly unit tests where Entity Framework seems to get in the way.

 

Automated Testing for ‘Fraidy Cats Like Me

Sometimes learning about Automated Testing from the testing gurus might be a little daunting. It’s hard for them to relate to the fears that developers who’ve never used automated tests before – especially those of us who have been coding for years and years. This will not be a "drink the unit testing or TDD Kool-Aid" session. Instead, I will share revelations that have helped me ease myself and clients into automated testing. Not only has it benefitted my development process, but looking at code from the perspective of "can I test this?" has resulted in a huge improvement in how I design my application architecture. Come dip your toe in the water and see if automated testing might be for you.

EF Code First Book (Ebook) 1/2 price today (April 25) at O’Reilly

O'Reilly Media

Deal of the Day

Discover Our 5-Star Ebooks for 2013

Save 50% on the Top 25 – Today Only

cf5star

We keep a running tally of our top-performing, five-star titles. These are the books that have most impressed and earned praise from readers like you. We’re now sharing the list with the added incentive of a special offer: for one day only, get these five-star ebooks for 50% off.

Ebooks from oreilly.com are DRM-free. You get free lifetime access, multiple file formats, and free updates. Sync with Dropbox — your files, anywhere.

View the 5-Star Rated Ebooks   →

Use discount code: DEAL
This deal expires April 25, 2013 at 11:59pm PT and cannot be combined with other offers. Offer does not apply to Print, or "Print & Ebook" bundle pricing.

Getting Started with WCF Data Services 5.4, OData v3 and JSON Light

TLDR: Setup steps to get WCFDS 5.4 up and running

JULBS (Julie’s Usual Lengthy Back Story):

WCF Data Services (aka WCFDS) updates are being released at a rapid pace. I think they are on a hoped-for 6-week release schedule and they just released 5.4 a few days ago.

One of the reasons is that they are adding in more and more support for features of OData v3. But rather than waiting until ALL of the features are in (by which time OData v4 may already be out! :)) they are pushing out updates as they get another chunk of features in.

Be sure to watch the http://blogs.msdn.com/astoriateam blog for announcements about release candidates (where you can provide feedback) and then the releases. Here for example is the blog post announcing the newest version: WCF Data Services 5.4.0 Release.

I wanted to move to this version so I could play with some of the new features and some of the features we’ve gotten starting with v 5.1 – for example the support for the streamlined JSON output (aka “JSON light”) and Actions & Functions.

As there are a number of steps involved for getting your WCFDS to use v 5.4, I somehow performed them in an order that left me in the cold. I couldn’t even get JSON light output.

So after scratching my head for way too long, I finally started the service from scratch and this time it worked.

  1. Create a new project to host your service. I recommend a WCF Services Application project
  2. Delete the IService1.cs and Service1.cs files created in the new project.
  3. Add a new WCF Data Service item
  4. Remove the references to the following WCFDS 5.0  assemblies:
    1. Microsoft.Data.Edm
    2. Microsoft.Data.OData
    3. Microsoft.Data.Services
    4. Microsoft.Data.Services.Client
    5. System.Spatial
  5. Using Nuget, install WCF Data Services Server. The current version available on Nuget is 5.4.
    When you install this, Nuget will also install the other 4 assemblies (Edm, OData, Services.Client and System.Spatial)
  6. UPDATE! Mark Stafford (from the WCFDS team) let me in on a “secret”. The WCFDS template uses Nuget to pull in WCFDS5 APIs, so you can just use Nuget to UPDATE those assemblies! (this is for VS2012. For VS2010, use the crossed out steps 4 & 5 :))

image

  1. Install Entity Framework 5 from Nuget

That should be everything you need to do to have the proper version of WCFDS.

Now you can follow a normal path for creating a data service.

In case you’re not familiar with that the basic steps (just getting a service running, not doing anything fancy here)

  1. Add reference(s) to any projects that contain your data layer (in my case a data layer with EF’s DbContext) and domain classes.
  2. Modify the WCFDataService class that the Add New Item wizard created so that it uses your context. My context is called CoursesContext, so here I’ve specified that context and simply exposed all of my entity sets to be available as read-only data using the SetEntityDataAccessRule. That is not a best practice for production apps but good enough to get me started.
 public class MyDataService : DataService<CoursesContext>
    {
    public MyDataService()
      {
        Database.SetInitializer(new CoursesInitializer());
      }

        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
            config.UseVerboseErrors = true;
        }
    }

 

My data layer includes a custom initializer with a seed method so in the class constructor, I’ve told EF to use that initializer. My database will be created with some seed data.

Notice the MaxProtocolVersion. The WCFDS item template inserted that. It’s just saying that it’s okay to use OData v3.

I added the UseVerboseErrors because it helps me debug problems with my service.

Now to ensure that I’m truly getting access to OData v3 behavior, I can open up a browser or fiddler and see if I can get JSON light. JSON light is the default JSON output now.

WCFDS now lets me leverage OData’s format parameter to request JSON directly in the URL. I can even do this in a browser.

Chrome displays it directly in the browser:

image

Internet Explorer’s default behavior for handling a JSON response is to download the response as text file and open it in notepad.

In Fiddler, I have to specify the Accept header when composing the request. Since JSON light is the default, I only have to tell it I want JSON (application/json).

image

Fiddler outputs the format nicely for us to view:

image

If I want the old JSON with more detail, I can tell it to spit out the odata as “verbose” (odata=verbose). Note that it’s a semi-colon in between, not a comma.

image

(I’m only showing the JSON for the first course object, the second is collapsed)

image

Checking for the existence of the JSON Light format and that it’s even the new JSON default, helps me verify that I’m definitely using the new WCFDS APIs and getting access to the OData v3 features that it supports. Now I can go play with some of the other new features! 🙂