All posts by Julie

Some Observations While Playing With EF7 Alpha Bits: EF7-Able Projects

You can’t install EF7 into just any project. Especially now that they are making the shift to focusing on ASP.NET 5 for it’s initial release.

Here are combinations that will work:

(Have not tried VS2012 ..)

Visual Studio 2013

.NET 4.5.1 projects only

Class Library, Client Projects (WPF, Console, Windows Forms), ASP.NET Projects, WCF

Later in 2015, EF7 will return to working with Windows Phone/Store, but for now, none of the relevant projects will host EF7 (e.g. universal apps, PCLs, etc)

Visual Studio 2015

.NET 4.5.1+ projects only

Class Library, Client Projects (WPF, Console, Windows Forms), ASP.NET Projects, WCF

ASP.NET 5 vNext Console & Class Library projects (and yes, the first sounds like an oxymoron)

image

ASP.NET apps (and if you’re looking for vNext, those are in the templates)

image

Some Observations While Playing With EF7 Alpha Bits

My first coding foray into EF7 was as a code monkey for Pranav  Rastogi from the ASP.NET team at TechEd Europe where he walked me through converting a simple EF6 app to EF7. (“Entity Framework Now and Later”, my bit starts at about 50 minutes in.) My next EF7 playtime was working through demos created by Rowan Miller (program manager on EF team) that are available here on his github account: https://github.com/rowanmiller/Demo-EF7/.

These demos depend on a snapshot in time of EF7 alpha  (EntityFramework.7.0.0-beta2-11514)  and demonstrate using EF7  & SQLite in a Windows Phone and Windows Store app as well as against a non-relational database (in this case Azure Table Storage). It also demos some other new features like batched updates, improved LINQ queries and more.

I used these same demos for a conference presentation which meant I practiced them repeatedly and modified them a bit to make sure it flowed in the way I preferred.

The bits are evolving rapidly. I’ve since been reading and writing about EF7 and played just a little but now I’m starting to have my most fun which is asking myself “what happens if I do X? what happens if I do Y?”, debugging, comparing and contrasting behaviors.

With the caveat that EF7 is still alpha and things are still evolving and shifting, I wanted to share some observations as I am playing with it.

1) InMemoryStore Before Committing to a Data Store

When you do any interaction with the DbContext even if you are not trying to query or save data, EF7 still wants you to specify the data provider in DbContext configuration.  Since I’m not yet interested in actually hitting a database, the new InMemory provider is the perfect foil!

In DbContext, I can install the entityframework.InMemory package then specify in my DbContext class that this is the provider I want to use and then I’m good to go.

protected override void OnConfiguring(DbContextOptions options)
{
  options.UseInMemoryStore();
  base.OnConfiguring(options);
}

I’d used InMemory for unit tests already but I was just using a simple console app to fiddle around EF7 with. That’s still testing, and that’s what the InMemory provider is for – testing.

What I’d like to do is be able to switch the context on-the-fly to use in memory store so I can have a single defined context with all of it’s dbsets, mappings etc and switch it easily to use my real data store or the InMemory store. So in a test project, I’d be able to say “use the context, but for these tests, use the InMemory store”. I see notes on github that this is a goal – e.g. specify provider along with connection string in a configuration file.

Rather than an enormous blog post, I’ll just publish this first bit and add more in bits and pieces …kinda how EF7 is being built anyway. Smile

EF6 Ninja Edition Course is Live on Pluralsight

It’s been a long haul and a long wait. I started work on this course, then switched gears to work on the Domain–Driven Design Fundamentals course with Steve Smith. When I returned to work on the EF6 course, a number of minor releases and patch releases had been published so I had to revise much of what I had already recorded, edited and produced.

But today, finally, the full course has been published on Pluralsight.

Entity Framework 6: Ninja Edition
– What’s New in EF6

It is a little over 7 hours long. This is what I would have done had I written another huge book. So if you are looking for my next book, just watch this course! And you can go back to it for reference.

If you don’t have a Pluralsight subscription (and honestly, the $29 monthly fee if you were to just subscribe to watch this course, is less than those huge books), send me a note and I’ll send you a code for a trial. You’ll probably realize quickly that you want a subscription though to continue accessing the enormous library.

Course Description

Entity Framework 6 brings major improvements to EF that allow developers to align their data access with advanced software practices. The biggest news for EF6 is that it is open-source and has gained a lot from developer community input. Features with broad appeal such as stored procedure mapping in code first, support for the Async/Await pattern when executing queries and commands, simpler patterns for unit testing, and built-in database logging capabilities have gotten a lot of visibility. EF6 is now very extensible with custom Migrations, custom mapping conventions, and the introduction of Dependency Injection patterns to open up low-level DbContext configuration. There are new methods and properties that allow simpler and smarter coding patterns. Rather than present a high level list of the new features, this course dives into each new feature in EF6, ensures that you understand not only what it is for, but how it works, scenarios where you can benefit from it, and gotchas you should watch out for. This course provides a comprehensive look at what EF6 adds to Entity Framework, and it will leave you with the ability to truly benefit from all of the Ninja power that’s been added to this version of EF.

Course Outline

Overview of What’s New in EF6

Introduction

What Is Entity Framework?

What’s in This Course?

What’s in This Module?

A Brief History of Entity Framework

Why EF6?

A Lap Around EF’s CodePlex Site

Overview of Changes to the EF Designer

Overview of New Features

What’s Not (Yet) in EF6

Summary

Resources

Getting to EF6

Introduction

In This Module

Getting EF6 Into New and Old Projects

Updating Projects to EF6

Summary

Resources

Performance and Stability Improvements

Introduction

In This Module

Faster Processing of LINQ’s Enumerable Contains

Faster Mapping View Generation

Using nGen to ‘Pre-JIT’ EF6 Assembly

Reuse Open Database Connections

Create DBs That Are More Scalable and Less Prone to Deadlocks

Connection Resiliency for Transient Database Connections

Digging into the Connection Resiliency Feature

Quick Review

Resources

Changes to the EF Tooling

Introduction

EF Designer History

In This Module

EF Designer’s New MSI Installer

Creating a Code First Model From a Database in the Designer

Database Views in Your Code First Model

Customizing the Code First Designer Templates

Refactoring the Generated POCOs and Model

A Warning About a Naming Conflict With Code First From Database

What Does the Empty Code First Model Wizard Do?

Comparing the Code First Model Wizard to the EF Power Tools

Using EF4 or EF5 With the New Designer

A Notable Change to the Model First Workflow

Why You Still Need the EF Power Tools

Quick Review

Resources

Stored Procedure Mappings for Code First

Introduction

In This Module

Understanding EF Stored Procedure Mappings

Visualizing Stored Procedure Mappings

Differences Between Designer-Based and Code First Model Mappings

Conventions for Procedures Created by Code First

Customizing Mappings to Work With Existing Stored Procedures

Quick Review

Resources

Custom Code First Conventions

Introduction

In This Module

Custom Code First Conventions: Why Would You Want Them?

Custom Conventions Basics With Lightweight Conventions

Using Attributes to Specify Custom Conventions

Encapsulating Custom Conventions

Understanding and Controlling Execution Order

Model-Based Conventions

Extending Existing Conventions

Quick Review

Resources

More Code First Goodies

Introduction

In This Module

Database Index Support in Code First

Adding Indexes With Fluent API

Setting the Default Database Schema

Using AddFromAssembly to Load Conventions and Configurations

Understanding and Fixing How Code First Pluralizes Table Names

Using a PluralizationService to Localize Non-English Table Names

Implementing a Custom Pluralization Rule in Your Data Layer

Mapping to Results of Table Value Functions and Stored Procedures

Quick Review

Resources

Enhancements to Code First Migrations

Introduction

In This Module

Affecting the Schema of the Migrations History Table

Smarter Migrations With Idempotent Scripts

Limitations of Existing Migrations Methods

How Migrations Get From Method to SQL

Create Custom Migrations for Other Database Operations

Why HasColumnAnnotation and HasTableAnnotation?

Implementing a Simple Table Annotation

Implementing More Complicated Annotations

Performance Tweak for MigrateDatabaseToLatestVersion Initializer

Migrate From Multiple Models to a Single Database

Using HasDefaultSchema and ContextKey for Multiple Model Support

Easier Migrations for Multiple Models in a Single Project

Combining Database Initializers and Migrations

Quick Review

Resources

Improved Database Interaction

Introduction

In This Module

Simple Database Logging With the Log Property

Tweaking the Log Functionality

SQLCE Functions for LINQ Queries

Introducing the Async EF6 Methods

Demonstrating the Effect of Asynchronous EF6 Methods

Perception and Performance: Load Testing With Async EF6

Quick Review

Resources

Code-Based DbContext Configurations and Interceptors

Introduction

Why DbConfiguration?

In This Module

Creating and Triggering a DbConfiguration Class

Why Move Config File Settings to Code?

Moving Connection Factory to DbConfiguration

Moving Database Initializers to DbConfiguration

The New NullDatabaseIntializer

Provider Services and DbConfiguration

Tap into the Pipeline With Interceptors

Beyond the Interceptor Basics

What Stops Does the DbCommandInterceptor Make in the Pipeline?

Building an Interceptor for Database Logging

Using Interceptors to Solve Complex Problems

Understanding the Role of Dependency Resolution

Hosting DbConfiguration in External Assemblies

Quick Review

Resources

Sometimes It’s the Little Things

Introduction

In This Module

EF6 and Mocking Frameworks

Writing Tests to Mock Methods Like DbSet.Find

Writing Tests to Mock LINQ Queries

Nested Entities and Complex Types

Fixing the Ambiguous Types Problem

Custom Equals vs. Change Tracker Equals

Smarter LINQ to Entities Queries

Yes, You Can Haz Changes With HasChanges

Quick Review

Resources

My TechEd Europe Schedule

 

TEEU_2014_I’m speaking_1I’m so very excited to be heading to Barcelona shortly for TechEd Europe. You may or may not be aware of my dashed hopes last year when I was scheduled to speak at TechEd Europe in Madrid. But when I found myself stuck in the Chicago O’Hare airport on my 2nd day of travel, only to be told I wouldn’t get to Madrid until Thursday afternoon (after 4 days of travel) it was time to turn around and go home. I also had scheduled a post event side trip to Barcelona – this too, I canceled.

I was a little surprised that TechEd was willing to try again considering my bad history but I will be speaking at the 2014 version of the event.

Not only am I looking forward to my first ever trip to Spain and the amazing city of Barcelona, but it will be my first opportunity to meet so many developers that I’ve never met before.

My Session

My talk is on Friday, Oct 31 at 12-1:15pm. Yes, on Halloween!

Entity Framework Model Partitioning in Domain-Driven Design Bounded Contexts
Bounded Context is one of the most critical patterns in Domain-Driven Design (DDD). While you shouldn’t have to worry about your data persistence while you are modeling your domain, it is still worrisome to follow DDD patterns not knowing how you’ll get your ORM to fall in line when it’s time to implement the data layer. Entity Framework sample solutions have a long history of creating one huge model to map to one huge database to satisfy all of the needs of your application. In this session we look at patterns using Entity Framework that will support not only multiple bounded contexts in your software but even those areas that are satisfied with pure CRUD logic. You also see patterns to bridge the divides between those bounded contexts when implementing the data persistence with Entity Framework.

Getting the Most Out of My Session

Dino Esposito will be doing a relevant talk on Tuesday that will be useful if you are new to Domain-Driven Design.

DEV-B211 Architecting and Implementing Domain-Driven Design Patterns with Microsoft .NET  Tuesday, October 28 1:30 PM – 2:45 PM Room: Hall 8.1 Room G

I’d also recommend watching the Domain-Driven Design Fundamentals course that Steve Smith and I created for Pluralsight. It’s about 4 hours long and is a great first look as well as a refresher on some of the key concepts of DDD. You’ll definitely get a lot more out of my talk if you’ve seen this in advance. If you don’t have a subscription to Pluralsight, send me a note and I can get you a 30 day trial code.

Where to Find Me

Here is my current schedule. This does not list talks I plan to attend, but the opportunities I will have to meet people and geek out! Smile

image

So much bling, I just can’t choose!

TEEU_2014_I’m speaking_4TEEU_2014_I’m speaking_1TEEU_2014_I’m speaking_3

A Pattern for Sharing Data Across Domain-Driven Design Bounded Contexts

My latest MSDN Magazine column  – October 2014 issue – has just gone live.

A Pattern for Sharing Data Across Domain-Driven Design Bounded Contexts
Julie Lerman explores a way to mirror data as one scenario for sharing data across DDD bounded contexts.

Even though the solution is available for download, it involves installing and running RabbitMQ and learning my way around the server’s UI. For me that was a fun and almost freeing step of building the solution. It even meant installing Erlang on my laptop. Lots of fun but lots of learning curves.

But it may be more than some readers want to commit to. So I recorded a video of me debugging through the solution so that you can see how it works.

I recommend reading the article first and watching the Domain-Driven Fundamentals course that Steve Smith and I created for Pluralsight will really help. If you don’t have a Pluralsight subscription yet (really?) send me a message through my contact form and I can hook you up with a free trial. Warning…can lead to addiction.

Anyway, here is the video. There is no sound…I’ve used captions to explain. [youtube http://www.youtube.com/watch?v=N55t2g0cRRQ?rel=0]

DDD Fundamentals Course is Making a Difference

Steve Smith and I are so happy to be getting this kind of feedback about our Domain-Driven Fundamentals course on Pluralsight. We wanted to give developers help understanding the basics so that they can dig in to more indepth resources like Eric Evans’ or Vaughn Vernon’s books.

Here are some recent tweets we’ve seen.


Ryan Moseley @bahamaboy85

Completed the DDD Fundamentals course from @pluralsight by @ardalis @julielerman http://pluralsight.com/courses/domain-driven-design-fundamentals …. This course makes DDD accessible.

It is tough to find DDD examples that don’t assume some level of knowledge. So this course is welcomed.


Tom Davis @photomoose · Sep 9

@julielerman Just watched your DDD course on @pluralsight. Probably the best intro to DDD I’ve seen; things make sense now!


Paul Hale @paulhale · Aug 29

@pluralsight @ardalis @julielerman cracking #DDD course + @ericevans0 book set me on right track. Ironically Im building a domain reg system


Félix-A. Bourbonnais @fbourbonnais · Aug 11

Good #DDDDesign course by @julielerman @ardalis. Key concepts of DDD are well explained. I recommend http://owl.li/AcX4q


Geoff Mazeroff @geoffmazeroff · Jul 30

My work project uses DDD, so I enjoyed hearing @ardalis and @julielerman present the fundamentals on their @Pluralsight course. Nice work!


Mike Sussman @mikesussman · Jul 25

Finished @pluralsight DDD Fundamentals course by @julielerman and @ardalis, makes a lot more sense now.

What About EDMX When EF7 Arrives?

I’m getting a lot of folks asking me about the announcement that EF7 will focus on code first and there will be no support in EF7 for designer based EF models.

I’ll give my two cents, even though I do think the EF team has been pretty clear about this in both their blog post about EF7 plans 

EF7 – New Platforms, New Data Stores

and in Rowan Miller’s TechEd talk where he devoted the last 20 minutes to early look at early bits and early thoughts about EF7

Entity Framework: Building Applications with Entity Framework 6

Here’s the scoop: EF6 and the designer will continue to be available and worked on but the big effort will go into EF7 going forward. Personally, I can’t promise it will be around 10 years from now so please don’t bang down my door in 2024.

I’ve also been asked: “should I bother learning about the EDMX since it will not be in EF7?” I firmly believe that learning a bit about modeling via the designer helps get some of the concepts across for if/when you do code first modeling.

Also don’t forget about some of the 3rd party tools that provide designer support such as LLBLGenPro, Huagati Tools,  and DevArt’s Entity Developer. I’m guessing they will be moving their tools forward, though I haven’t looked into it yet.

Capture Screenshots Directly into Camtasia Projects

I spend a lot of time in TechSmith’s Camtasia when I’m building my Pluralsight courses. I’ve been using it for years and am a huge devotee. (disclsure that I get a free licnese as a Microsoft MVP but would willingly pay for it). often decide while editing that an image would be handy. I usually have to go grab a screenshot, save that file. Then import that file into my camtasia project and then put it into my video.

I also happen to use TechSmith’s SnagIt for my screen captures (same disclosure re free license and same but I would pay for it for sure!).

I only just discovered that there are a slew of output extensions for Snagit and one of them is Camtasia.

Here is a 30 second video (that I created in Camtasia of course) of how it works.

[youtube http://www.youtube.com/watch?v=6TaLJu-h6iQ?rel=0]