Tag: entity framework

Mocking async repository calls

Mocking is a great technique for isolating code that you want to test. By mocking the interfaces a code section depends on you can create an isolation level where only the behavior of this specific code section is being tested. In my example I have a ProfileService (BLL) that takes an IProfileRepository interface (DAL) as

Database related attributes in Code First

This post is a follow-up on the post about Validation attributes in Code-First. While validation attributes focus on making sure the data in the model is correct, the attributes listed here instead focus on instructing Entity Framework’s database generation engine how the database should be structured. Column Specify what column name to use for this

Validation attributes in Code First

DataAnnotations are really helpful when creating a model in Entity Framework Code-First. They are a simple way of instructing EF how you want the model to be structured and how it should translate the model into a relational database. You can also use validation rules to specify what values are allowed in your parameters. When

When both update-database and add-migrations fail while referring to each other

Today I checked out a project from Git on a new machine. The project was using Entity Framework to connect to a local SQL Server on my developer machine. To install the database I ran update-database in the Package Manager Console and got an error message complaining about “pending changes” and that I should run

%d bloggers like this: