Lee Naylor
Lee Naylor
Newton-le-Willows, Merseyside, UK
Any source code or other supplementary materials referenced by the author in this text are available to readers at www.apress.com . For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/ . Readers can also access source code at SpringerLink in the Supplementary Material section for each chapter.
ISBN 978-1-4842-2136-5
e-ISBN 978-1-4842-2137-2
DOI 10.1007/978-1-4842-2137-2
Library of Congress Control Number: 2016952810
© Lee Naylor 2016
ASP.NET MVC with Entity Framework and CSS
Managing Director: Welmoed Spahr
Lead Editor: Celestin Suresh John
Development Editor: Laura Berendson
Technical Reviewer: Fabio Ferracchiati
Editorial Board: Steve Anglin, Pramila Balan, Laura Berendson, Aaron Black, Louise Corrigan, Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, Nikhil Karkal, James Markham, Susan McDermott, Matthew Moodie, Natalie Pao, Gwenan Spearing
Coordinating Editor: Nancy Chen
Copy Editor: Kezia Endsley
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
For information on translations, please e-mail [email protected] , or visit www.apress.com .
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales .
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Printed on acid-free paper
I would like to dedicate this book to two special women in my life; my late mother Pauline, who sadly passed away while I was drafting the first few chapters, and my wife, Michelle. To Mum, thanks for always being there for me and I miss you every day, and to Michelle, thanks for all your support during difficult times, for giving me our wonderful son Peter, and for finding my best friend, our dog Chocky.
I decided to write this book for people who learn by doing. I’ve read several software books over the years where you can read the whole book and learn many things but never quite put the full pieces of the jigsaw together. This book aims to allow the user to follow a step-by-step guide to learn how to use ASP.NET MVC with Entity Framework, while sticking to all the main topics you will encounter in everyday work scenarios, without focusing on academic details that very few people will ever use. I’ve tried to keep things relatively close to real life in the book, which is why I chose to make a baby store, but the examples can be applied to almost any type of shopping web site or indeed any web site driven by a database. I’ve also included a redesign of the site, including several popular CSS topics to recognize the fact that these days web developers need to be competent in front-end development too.
The book starts with an introduction to Microsoft ASP.NET MVC and then quickly progresses into showing you how to create a database driven web site, and from this how to enhance the site and use some of Entity Framework’s more advanced features. I’ll show you how to work with related tables and data, how to create and update a database schema, and how to populate data from your code.
I also cover how to use Microsoft Identity to add some user authentication and authorization to the site along with roles, and how to manage both of these. You’ll also learn how to deploy to Azure to allow your site run over the Internet.
The latter part of the book focuses on restyling the web site using CSS, with an introduction to jQuery thrown in, with the goal of this section being to get you up and running from basic to advanced CSS as quickly as possible.
The book mainly covers using ASP.NET MVC 5 with Entity Framework 6, which are the most widely used versions at the time of writing; however, it also includes an introduction to ASP.NET core and shows you how to create a basic web site and database.
The full source code for the examples shown in the book is available for download from http://www.apress.com .
I want to thank everyone I’ve worked with at Apress for their help in taking an idea and turning it into a reality. In particular, I want to thank Nancy Chen for keeping everything moving along, and to former Apress employee James DeWolf, for taking me on in the first place.
I’d like to thank my wife (again) for all her support and putting up with my lack of time and my day-dreaming about how to code something when she’s trying to have a real-life conversation with me about nappies.
Lee Naylor is a software engineer from Manchester in the United Kingdom with expertise in programming and Agile project management. He spends his free time with his family, playing football (soccer) and golf.
Fabio Claudio Ferracchiati is a senior consultant and a senior analyst/developer using Microsoft technologies. He works at BluArancio S.p.A ( www.bluarancio.com ) as a senior analyst/developer and Microsoft dynamics CRM specialist. He is a Microsoft Certified Solution Developer for .NET, a Microsoft Certified Application Developer for .NET, a Microsoft Certified Professional, and a prolific author and technical reviewer. Over the past 10 years, he’s written articles for Italian and international magazines and co-authored more than 10 books on a variety of computer topics.