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.

This past Friday, I had the pleasure to present a full day of content at day 1 of Philly Code Camp. My talk has an odd title: “End to End Development With Schwammy’s Favorite Patterns and Practices” This was the fourth time I did this talk and it has sold out very quickly each time so far. So I guess the silly title makes sense to people. Or maybe it’s that they read the description:

To create excellent software, you need to know a lot more than just the language basics. If you are an experienced developer looking to take things to the next level, this talk is for you. In this talk I’ll present many patterns and practices that I use as a Technical Architect. I’ll review and demonstrate many of my favorite patterns such as SOLID, Repository Pattern, Unit Of Work, Dependency Injection, etc. I’ll show how these patterns can be used for both server and client side development in ASP.NET MVC. I’ll demonstrate great ways to use TFS for automating your builds and deployments. During this full day session I will create a web application using VS2015, C#, ASP.NET MVC, Entity Framework, SQL Server, Bootstrap, Knockout.js and ELMAH. Unlike in traditional short talks, with the full day session you’ll see how all the pieces fit together. As always, I’ll throw in lots of tips and tricks along the way. FYI: this is a repeat (with some updates) from my popular full day session from the last Philly Code Camp. The session will not be hands-on for attendees however I’ll provide the complete solution with which you can review and experiment.

It’s a jam packed day – about 7.5 hours of me talking. I’m truly honored that people sign up to spend the day with me. Thanks to all of the attendees who participate and ask questions and make it a great day. Of course, a big thanks to the Philly.Net team Bill Wolff, Rob Keiser, Ken Lovely and a bunch of other great people who run that event so well year after year. I know how hard it is since I used to be one of them Smile.

So here is all the content. I’ve posted it before but this is the most up to date version:

Good luck, it was never really meant to stand on its own so it may not make sense. If you have any questions, let me know.

Did you know that early bird registration is now open for TechBash 2017? I can’t believe it is 2017 already, I never even got to write up a TechBash 2016 recap post!

TechBash 2017 | October 4-6, 2017 | Kalahari Resort, Pocono Manor, PA

If you attended our last TechBash, you know it was great. So now is a good time to take advantage of the early bird pricing. All 2016 attendees received a special discount code that can be used before January 31. If you didn’t attend, you can register for $279 for TechBash 2017. Prices go up Jan 31.

What should you expect from TechBash 2017? Great speakers, great content, great venue. We are currently working on getting a list of talks for 2017. But I can tell you now that most of the presenters have said they’d like to be back for 2017. Here are some of the comments we received from our evals. I think the quotes tell the story nicely.

Having a conference of this caliber in NEPA [North Eastern PA] is awesome. The speakers were all friendly and accessible enabling deeper conversations regarding their presentations and related topics. It was a wonderful event and the content was perfect.

Really, I thought everything was covered quite well.  Nitty gritty implementation and syntax seminars?  Check.  Higher-level software planning seminars?  Check.  New and coming tools and libraries?  Check.  Inspirational keynote talks?  Yep.  Fun?  Absolutely.   I have all good things to say to our team upon returning, who will no doubt be a little jealous they didn’t attend this year.  We will likely have a bigger group attending next year.  Keep up the great work.

Really good conference.  I will definitely be returning next year.  I had a great time

This was my first major/multi-day conference and it was a great experience. Thank you to the organizers and speakers, I am definitely looking forward to attending again in the future. I was also inspired to one day hopefully speak in front of a group of developers.

Great first conference, looking forward to next year!

Speaking for the organizers, the conference went pretty smoothly, especially for a first time event. Mostly, the only problems that were obvious to any attendees were the occasional “presenter can’t connect to the projector” issues. And thanks the awesome tech staff at the Kalahari, these situations were quickly resolved. We heard a ton of feedback about how great the presenters were, people loved the venue and waterpark, and (this is real and I was quite surprised) people said we had the best lunch of any conference they attended! This event had a great community feel to it. Presenters, attendees, sponsors, and staff all learned from each other over 3 days. Lots of new friendships were made.

Oh, and if you enjoyed the waterpark, you’ll be glad to hear that phase 2 will be completed this spring. That means a total of 200,000 sq. ft. of fun – doubling the size of the waterpark! Plus new restaurants, a ropes course and more!

Please check out TechBash 2017 for more information and to register. If you are not already on our mailing list, please sign up to get all the latest info.

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.