skip to content »

Error before updating scaffolding from new db schema

error before updating scaffolding from new db schema-31

I combined the UI and the Web Api as they are very similar and then provided a different approach for the business layer.

error before updating scaffolding from new db schema-42error before updating scaffolding from new db schema-49error before updating scaffolding from new db schema-35error before updating scaffolding from new db schema-33

I would recommend Edward Charbeneau‘s article ‘Giving Clarity to LINQ Queries by Extending Expressions‘ which has some excellent ideas and source code for building ‘query objects’. This isn’t done just to hide the database, but mainly to ensure that the developers working in the business layer are thinking about the business problem first, not how the database works.This needs a bit of thought, but isn’t that hard to do.By using LINQ and IQueryable requests then this allows paging and filtering to be added at the last minute in the UI/Web Api end. Select function allows only the columns/properties you need to be read in. The result is an Open Source library called Generic Services which provides List, Detail, Create, Update and Delete functions on either the EF data classes themselves or more interestingly via DTOs linked to EF data classes. Sample Mvc Web App, which is a much more realistic example of a real application.Having decided that the Repository/Unit of Work pattern does not add anything to Entity Framework (EF) the question was how to tame EF to work with Domain-Driven Design principals.This post details my new approach to using EF and why it is better.In C# Extension methods are a great tool for building Query Objects.

If you have seen LINQ fluent commands then that is how extension methods work.

DTOs can extract all the various parts and either ‘flatten’ them into one class, or for collections extract only the parts of the data that the user wants/is allowed to see.

The important point is to design the transfer for reads from the database so that they turn into efficient SQL requests.

At the time I was fairly convinced, but I needed to write some real code to see how I would do things without a repository.

Well, four months on the answer is – I’m convinced.

Firstly the EF database classes need to be at the data layer level, so these classes aren’t really the right place to have business logic (I have a separate layer/assembly for that).