If you find yourself stuck because you need to use EF 6 features in an ASP.NET Core web app with Identity, don’t worry, it is easy!

Like many of you, I am trying to get all caught up with ASP.NET Core. It has some great features and I’ve been looking forward to using it. I finally have a new project to start so Core was my first choice.To expand on that a bit, I am using ASP.NET Core with the full .NET Framework. At this point, I don’t need to use .NET Core in cross platform scenarios.

It wasn’t long after I got started that I ran into what I thought was a big problem.Spoiler Alert: It wasn’t a big problem at all!

A new project created for ASP.NET Core (configured to use Individual Accounts for security) will be all loaded up with Entity Framework Core as well as Controllers and Views and Code to make all the authentication stuff work. This post isn’t about that. It was all working nicely. That is, until I needed Entity Framework Spatial Types with SQL Server. My website needs to calculate distance between two points, something that is surprisingly easy with the right tools. However, EF Core doesn’t yet support that! I’d needed EF 6 instead. Now, this is where I made my big mistake. I assumed that I couldn’t have EF 6 and EF Core in the same project so I removed all of the EF Core stuff. I began to set up EF 6 instead and ran into issues wiring things up with ASP.NET Core. To set up all of the Dependency Injection stuff and wire up services, you need code like this:

services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();

But it turns out that AddEntityFrameworkStores doesn’t exist in EF 6. This got me going on all kinds of research, trial and error. All for nothing.

You see, I was going about this all wrong.

Thanks to some help from Julie Lerman (Entity Framework Guru and fellow Microsoft MVP) and Diego Vega (from the EF team at Microsoft), I found out that I could in fact run EF 6 and EF Core in the same project! All I needed to do (after getting all of the EF Core nuget packages all loaded up again) was create 2 DbContexts! One with EF Core for the Identity stuff. And one with EF6 for my application logic (so I can use the spatial features including DbGeography). At first, I had a some namespace confusion because there are classes with the same names in EF 6 and Core. But that was easily resolved.

It’s great when the solution is so simple.

image

We are having a blowout sale on TechBash tickets. Plus, the Kalahari has extended our room discount (while supplies last). You can now attend TechBash (tickets and hotel) for under $650! Here is the news you need…

TechBash is Sept 28-30 2016, Pocono Manor, PA

Here are 3 great reasons to register for TechBash 2016

1. The Content is really awesome!

The first and most important reason to attend a tech conference is learning. We’ve got you covered with some of the best and most knowledgeable speakers from across the country! At TechBash you will get the facts from experts. Learn about web, cloud, DevOps, design patterns, and tools. Want to learn about Microsoft tech like ASP.Net, Azure, C# or Visual Studio? At TechBash you will get expert knowledge and great perspective because we have speakers from inside and outside of Microsoft. Here are some names to get you interested:

From Microsoft: Amanda Lange, Chris Risner, Dave Voyles, David Giard, James Tramel, Jeffrey Fritz, Joel Cochran, Pete Brown, Stephen Bohlen

Microsoft MVPs: Chris Woodruff, Iris Classon, James Bender, Jesse Liberty, Jim Wooley, Joseph Guadagno, Ondrej Balas, Oren Novotny, Sam Basu, Steve Michelotti, Kevin Hazzard, and organizers Alvin Ashcraft, Andy Schwam, Brian Minisi, Devin Rader

But that’s not all: We’ve got other top speakers including Glenn Bock, Joe Kuemerle, Kendall Miller, Ashley Grant, Bradley Holt and more!

image

Click here to see our full schedule!

2. The Location is great (and close by to many of you)!

Our venue, the Kalahari Resort is really cool. It’s a new Resort, Conference Center, and 100,000 sq. ft. indoor waterpark! TechBash is located in the Pocono Mountains in PA. That means it’s not only a beautiful setting, but it’s also really close. If you are in the northeast US and tired of flying cross country for tech conferences, TechBash is for you. We are less than a 2-hour drive from New York City, Philadelphia, and northern NJ. And this location is still within reasonable driving distance of many other major cities in the northeast, including Boston, Pittsburgh, Baltimore and Washington, DC!

clip_image004[4]clip_image006[4]clip_image008[4]clip_image010[4]clip_image012[4]

3. The Price is Right!

This Labor Day we’re celebrating everyone who puts in a hard day’s work by offering you the best TechBash deal yet.

Our best price ever: Buy your ticket between August 31st and September 7th using the promo code TBLABORDAY and we’ll knock $100 off the normal registration price and you get our discounted Kalahari hotel room rate of $159 per night. This offer is for a limited by room availability at the Kalahari so don’t wait.

Now is the time to register!

Talk to your company, and let them know great advantages of attending TechBash. Tell your boss that about the content and the savings. Talk to your family, and think about combining the conference with a long weekend of water park fun! If you want any other information, contact me or check out our website www.techbash.com.

TechBash 2016 is a non-profit, community run event.

techbash-2016The content for TechBash is really looking good. Ok, I am biased a bit because I am helping to run the event Smile.

But seriously, we’ve got great speakers coming in from around the country to share their knowledge with you. I’m excited about a lot of it but some areas really stand out. For us ASP.NET developers, so much is changing and there is a lot to learn. Now is the time to get up to speed. Here are a just a few of the talks that are sure to help:

Title: A Deep Dive on ASP.NET Core

Presenter: Jeffrey Fritz

Are you considering ASP.NET Core for your next project? In this session, join one of the Microsoft program managers responsible for this new development platform as we take an in-depth look at the new ASP.NET Core platform. We will cover how the new .NET command-line interface enables you to build applications inside and outside of Visual Studio. We’ll look at how to use ASP.NET Core with docker and how you can build re-usable components with NuGet integration. Attendees of this session will have a deeper understanding of the topics they need to deliver more effective and faster applications with ASP.NET Core.

If you don’t know Jeff, you should. For us Philly locals, Jeff is well known as he is one of us. He’s been speaking in our area for years (I’m pretty sure was at his first talk ever) and now he is a Senior Program Manager at Microsoft! Not only that, he’s a great presenter and writer! Yes, this is a great opportunity to get the info from someone who really knows his stuff. We are really lucky to have Jeff with us at TechBash. You can see Jeff’s full bio and view all of the sessions (although the list is still growing) on the TechBash website.

Title: Getting started with Entity Framework Core

Presenter: Jim Wooley

With the cross-platform version of .Net, Microsoft has had to rewrite many of the core components that we have come to depend on. If you include data in your applications, chances are you have used Entity Framework in the past. In this session, you’ll learn how to get started using EF Core and how to handle the changes in this version.

Lucky for us, Jim Wooley is traveling to us from Atlanta. He’s the author of the popular “LINQ in Action” which is an awesome book. He’s also a great, popular presenter at conferences around the country. You can see Jim’s full bio and view all of the sessions (although the list is still growing) on the TechBash website.

Title: A Lap around ASP.NET Core 1.0!

Presenter: Sam Basu

Man, naming products is hard! But change is in the air for ASP.NET developers, as vNext ushers in a new era. Let’s talk – .NET Core | ASP.NET Core 1.0 | Open Source | .NET Frameworks Changes| ASP.NET Runtimes | WebForms | MVC 6 | Cross-Platform Tooling | Omnisharp.NET | Homebrew | Yeoman | CLI with VS Code or Sublime Text | Docker. Join me as we explore all that’s new & shiny. This is one of the best times to be an ASP.NET developer – let me show you why!

 

Did you read the summary above? Can you see how much there is for us to learn to be ready for ASP.NET Core? Sam Basu is coming in to help us out. Sam Basu is a Developer Advocate at Telerik (now Progress). He’s also a popular speaker and you are sure to learn a lot. You can see Sam’s full bio and view all of the sessions (although the list is still growing) on the TechBash website.

So, is that all?

NOPE! There will be lots of other great sessions at TechBash 2016. Please check out the current list on our website. I’ll try to highlight more soon.

TechBash: Sept. 28-30, 2016

Kalahari Resort, Mt Pocono, PA

Purchase your tickets and book your room now! We have a limited number of tickets and hotel rooms.

I look forward to seeing you there!

ASP.Net Developers, it is time to change your attitude towards JavaScript. I know you hate it. I used to hate it too. But I’ve come to terms with JavaScript and now actually quite like it! It isn’t my favorite language but I’ve been working hard to understand this important client side technology.

Please don’t be offended by this post. I know I have lumped all ASP.Net developers into one category here. I know many of you are in the same place as I am, moving quickly towards understanding Javascript. I am, however, speaking to a large group of .Net web developers who have not yet started their journey. You know who you are.

I’m a C# MVP and, prior to this past summer, I spent 3 years doing Silverlight development. I truly believe that Microsoft was on to something with the concept of Silverlight. Like many developers, with regard to client side web development, I knew there had to be a better way to do things than JavaScript. Silverlight was a great attempt. It wasn’t perfect but the concept was good. Heck, I thought that anything that saved me from JavaScript was a good thing. I don’t care what anyone says, JavaScript is not the best solution to client side programing. I think we could have had better. Silverlight was a good try but people didn’t embrace it for various reasons (I won’t get into that in this post). Well here we are now and Silverlight is pretty much toast. It seems like Microsoft has thrown in the towel and isn’t trying to replace JavaScript and I doubt anyone else will pick up that fight.

For the past 8 months or so, I’ve been back doing “traditional” web development. I’m quite happy to be in the world of asp.net MVC with HTML, JavaScript, and CSS. In the past few years, a lot has changed. Three and a half years go, when I last did this sort of work as the main part of my job, jQuery was gaining a lot of traction and was becoming widely accepted. But not like it is today. Today, many developers incorrectly use the words JavaScript and jQuery interchangeably (which is actually quite annoying). And as great as jQuery is, there are a ton of other great JavaScript libraries to help us developers. Patterns like MVVM and SPA have gotten quite popular. And I’ve learned that there are some other great patterns that can be applied to JavaScript development that can make the experience much better, especially for a pattern-happy OO developer like me. So I have been reading up on and practicing using closures, the revealing module pattern, prototypes, MVVM, dependency injection, and more. And I haven’t even started with TypeScript which looks very interesting, to say the least. And I should also mention that products like Visual Studio (and many plugins too) have come a long way to finally embrace JavaScript and have started to treat it like a first class citizen.

In addition to the fact that doing client side development is much better these days thanks to frameworks and tooling, our users have come to expect a richer experience from web sites and applications. Users want web pages to be useable and responsive and, dare I say, “nice to use”. And so, fellow ASP.Net developers, the time for faking our way through JavaScript is over. I have put a lot of effort into learning more about JavaScript. I’ve started treating that part of my job as seriously as I do C#. I don’t expect that I’ll become some kind of JavaScript Ninja anytime soon, but I’ve realized that JavaScript enhanced UIs are an important part of my work. I’m giving JavaScript respect and I’ll expect other developers to do the same. No longer will I accept a job candidate’s dismissive answers about their knowledge of JavaScript. “Yeah, I can do a little JavaScript but I don’t like it” is no longer a valid answer to an interview question. JavaScript is an important aspect of our jobs as web developers and it isn’t going anywhere, at least not for a while.

I talk about this story a lot… few years ago in a team meeting the developers were complaining about their struggles in writing JavaScript which was becoming an important aspect of our web solution. Our manager, who is a really smart guy and still a friend of mine, asked a few questions that made a big impact on me. First he asked, “How many books have you guys read about C#?” The response varied across the team but we had all read a bunch of them. He followed that up with the knockout punch… “how many JavaScript books have you read?” The room was pretty quiet. Most of the group had read none. At least I had read one, but I was wasn’t much different than the group. JavaScript programming was part of our job but yet we didn’t take the time to learn it. And through my career I have found that most ASP.Net developer’s (myself included) experience with and towards JavaScript was pretty similar.

The age of treating JavaScript with disrespect is over. It’s a necessary part of our web solutions. And as I said earlier, the frameworks and tooling have gotten much better. So now is the time to learn it, embrace it, use it, and succeed with it.

When developing web sites, we should all be thinking “touch friendly”.

Now that I have a Surface RT tablet, I realize how bad so many websites are for touch devices like a tablet. Lucky for me my Surface has a keyboard with a track pad built into the cover. Because on numerous occasions I find myself stuck on a website and I need to switch to “keyboard” mode and use the track pad/pointer to be able to use some drop down menu type of input.  Obviously this didn’t matter for many years an there are a lot of old sites living across the internet. Over the years, I was just I was just as guilty of this bad programming technique as the next developer, we just didn’t need to worry about touch. But those days are over and I’m ready to make a change.

By the way, I’m not going to get into a rant about how bad most websites are to use on smaller mobile devices like phones! This is a similar issue but there is a difference.

As more and more people are using tablets as their primary device for the web, we developers need to get with the program and ensure that we give our guests a first class experience.

Here are a few simple tips to follow:

  • Don’t rely on hovering. Touch users don’t have a mouse pointer so they’ll be stuck.
  • Make targets large. If you expect a user to click something, think about the size of the average user’s finger.
  • Keep pages simple. It’s much easier for touch users to use your site if you keep things simple and uncluttered.

So fellow developers, please join with me in this New Year’s resolution by taking this pledge:

I, state your name, promise to start making websites and applications that don’t suck for touch devices. I promise to care about my users and build sites and applications that they can use easily.

Happy New Year! Good luck with this and all your other resolutions.