If you didn't notice, Entity Framework Core 2.1 has a new way to support seeding your databases with a method called HasData. Julie Lerman has a great new Data Points column in MSDN that explains how a lot of it works.
Go read that article first. It really covers the basics. Unfortunately, for my use, her article missed a tiny detail that I think is useful. But let's start with a brief overview of how HasData works.
I know I am not going to make everyone happy with this post. I've been hoping to not have to make this post, but Entity Framework Core has finally added support for Lazy Loading, so it's time.
This problem is not new. Entity Framework (not Core) also has this problem. But it's far easier to accidentally do this in that version. Luckily, Entity Framework Core has made it harder to inadvertently turn it on. Let's see what's wrong with Lazy Loading in Web Apps.
As many of you know, my recent course on Pluralsight dealt with Best Practices in ASP.NET: Entities, Validation and View Models. As I’ve worked with clients, there seem to be a non-ending list of ways to deal with data in ASP.NET.
One of the topics that I am passionate about as it relates to the course is how to manage the Model to Entity relationship. While being pragmatic is important, I still believe that there are many situations where you want a separate Model for a view (server or client-side) instead of just using the Entities that you’re storing data with.
For my upcoming course, I have a decent sized example that I’ll be teaching from. In the process of watching ASP.NET 5 go through the sprints, I have to upgrade the project at every step. I feel at some point I should be getting better at dealing with the sprints, but not yet ; )
Here is a short post that includes the different things I had to deal with in upgrading the project. It’s not just the ASP.NET 5 update, but also EF7 and a couple of small details.
NOTE: This post has been updated for changes in Beta 7 and later.
Every web project needs some sort of data framework and ASP.NET 5 is no exception. Like it’s forbearers, ASP.NET 5 uses Entity Framework, but this version of the Entity Framework is different. It’s being re-engineered from the ground up just like the ASP.NET 5 stack.
In this second post in my six-part series on ASP.NET 5, we’ll take a look at how your ASP.NET 5 applications will be configured upon startup. The startup in this new version of ASP.NET 5 is very different, but hopefully is clearer and easier to debug. At least that’s my impression so far.
If you haven’t read the prior topics, it would probably be helpful to start with the earlier articles. You can see a list of the links to the articles below:
In this new course I build a new web site from scratch. I start out with a Bootstrap template (since my design skills suck) and move through creating content, building a database, exposing a REST-ful API and building a Single Page Application. I wrap it up by publishing the site to Azure Web Sites showing you how to not only get your application up an running in the cloud, but also how to monitor it and handle standard tasks like using your own domain in Azure.
I like to write blog posts where I offer some pragmatic advice. In most posts I try to include tons of code samples and example projects...but this post is different. I am trying to get my head around something so I want to share what is in my head so I can get a conversation started with my readers to help me out. Once you read this post, please comment...
Pardon the link post, but this is a great short walk-through of using LinqPad to execute EF queries against your own model. Great for testing query ideas against your data. Highly recommended.
If you missed me in Bulgaria's DevReach conference, the video of my Silverlight Data Access talk is now available. The original talk's description was:
UPDATE: Roger Jennings correctly stated, I meant to say that Include is *not* a guarantee.
I've finally had a chance to update my Silverlight 2-ADO.NET Data Services example. In this new sample I show how to create a Line-of-Business application (an XBox Game editor) using ADO.NET Data Services against both an Entity Framework model and NHibernate. Unlike earlier examples, this one includes implementation against the ADO.NET Data Service Silverlight 2 library to support saving of changed entities. In addition, I show some techniques for paging, retrieving simple types over an ADO.NET Data Service and full styling of the application. I hope to add support for Forms Authentication in the coming weeks.
Data is a funny business. While at the moment I am spending a lot of time teaching Silverlight, my passion still lives in the data. I was brought up on Minisystems (Multi-user CP/M and the like) where you were dealing with something like a database (though we didn't have that as firm a concept as you might think). Later I did quite a lot of desktop database development starting with dBase II (yes, I am that old), Paradox, Clipper, FoxPro and even Access. That naturally led to client-server and N-Tier development. Throughout all the time its become exceptionally clear how much data matters to most applications.
But using databases can be difficult as there is an impedance mismatch with object-oriented development and the natural structure of data. The solution to this for many organizations has been to build data access and business object layers around the data. These layers were meant to simplify data access for most developers and embed the business logic directly into a re-usable set of code instead of it ending up in the UI layer. This was a good thing...
The Entity Framework "No Confidence Vote" is a couple of days old now. I wanted to give the Internet a couple of days to chew it over and figure out where it really fit into the big picture. If you follow me on Twitter you may have seen some back and forth between Scott Belware and I recently. Most of this back and forth has been about his attacks of the Microsoft community (attacks of the technology or even the company are fair game as far as I am concerned). Getting personal by accusing me, the Microsoft community or even individual EF Team member's directly seems petty and unnecessary.
In that same light, some of the ALT.NET community (I won't name names) have accused me of being a shill for Microsoft's techologies. Anyone who has ever seen me talk about any Microsoft technology already knows that I pride myself in my centrist view of any technology (Microsoft's or others).
I've known Julie Lerman (or is it Julia these days ;) for a long time now. She's an excellent resource for everything data related. In particular she's been keeping up with the Entity Framework and ADO.NET Data Services (formerly Astoria) updates in .NET 3.5 and VS SP1 Beta that was just released this week. If you are upgrading projects (like I am), she has two excellent blog posts about how to upgrade your projects:
Over the past week there have been a flurry of new projects coming out of Microsoft, mostly in the form of CTP's. I've been downloading like crazy and will likely be discussing my experience with them in the coming week. In case you missed any of them:
I expect that with the release of the EF Beta 3 means Astoria is coming soon. I'll let you know when it drops! Time to start digging in.
Come see me and Glen Gordon talk at Phipps Plaza in Atlanta about Visual Studio 2008, "Astoria", Entity Framework and Silverlight...and see them working gracefully together!
I've been digging into the latest version of the Entity Framework Beta (and designer CTP) that dropped a few days ago. I've concocted a small example that shows the derivation model in the Entity Framework. Essentially it is a small model that has a Product type and two types that derive from that: ActiveProduct and DiscontinuedProduct:
The ADO.NET team has been working hard on a new release of the Entity Framework with a boatload of new features (I haven't played with it yet, probalby this weekend). I know they are under some pressure as the June CTP shipped on July 2nd. Check it out if you want to see where they are going.
|Vue.js by Example (Now Available)|
|Bootstrap 4 by Example|
|Intro to Font Awesome 5 (Free Course)|
|Building a Web App with ASP.NET Core, MVC6, EF Core, Bootstrap and Angular (updated for 2.1)|
|Using Visual Studio Code for ASP.NET Core Projects|
|Implementing ASP.NET Web API|
|Web API Design|
|Application Name||WilderBlog||Environment Name||Production|
|Application Ver||v4.0.30319||Runtime Framework||x86|
|App Path||D:\home\site\wwwroot\||Runtime Version||.NET Core 4.6.26725.06|
|Operating System||Microsoft Windows 10.0.14393||Runtime Arch||X86|