Enable Entity Framework Core (1.1.1) Migrations From Separate Assembly

Watch the video if you don't like reading: So, today I tried updating all my project packages to dotnet core 1.1.1. Everything went pretty well except the EF Core's 1.1.1 update. Like everyone else I like putting my DbContext and Repository files in a seperate assembly. A barebone DbContext class may look like this: public class ApplicationDbContext : DbContext { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } } Up until 1.1.0 I was able to run migrations. But today when I tried to add a…

Keep reading

Smart Technical Debt Estimation with NDepend

It’s been less than a year since I last wrote a blog about NDepend. And here again, I’m writing about an awesome static analysis tool that everyone likes. I must confess that I had no idea on static analysis and analyzer before having an encounter with NDepend. Only after going through NDepend, have convinced me that this type of tool can really make our developing/managing life plain, simple and easy. However, in the middle of the last year I was totally converted to a guy who now…

Keep reading

Implementing Common Audit Fields with EF Core’s Shadow Property

One of the coolest feature of EF Core is, you can define properties that don’t exists in the Entity class. They are called shadow properties. While working on EF6, I needed some common audit fields that every entity will extend. Like, when a row of a table is updated, when a row is created, what is the row version etc. Since there was no concept of shadow properties in EF6, what I and many other developers did is create an interface with those common fields and implement that interface…

Keep reading

Building Custom Formatters for .Net Core (Yaml Formatters)

Quite recently I got myself introduced to .net core’s formatters. In short, what formatters do is format your response and request in your preferred data formats. For example, Json formatters, if used would format your response (returned value from controller's action) and request (value passed as a parameter to the controller) in Json. Same goes for the XML and other formatters. .Net Core gives you some formatters out of the box. This official documentation link described them briefly https://docs.microsoft.com/en-us/aspnet/core/mvc/models/formatting But…

Keep reading

Dependency Injection to The Core (Part - III)

We came to know about the term IoC container. There are many IoC containers available and most of them do the same things somewhat differently. Let’s use one of them in our current project. Let’s pick Autofac which has a great documentation online. Here is the link where you can know all about the Autofac integration related stuff with Web API projects, http://autofac.readthedocs.io/en/latest/integration/webapi.html Since we are just beginners wondering around the world of dependency injection. We will go slow and…

Keep reading

Dependency Injection to The Core (Part - II)

Say for example, our client changed their requirements and now wants us to read and write comma separated data (CSV) from a filesystem instead of a database. Suppose I’ve searched and downloaded a cool library that can work with CSV files. So, we have a CSV library configured and ready to talk with our CSV files in the data access layer. If you are following me then you would say, now that we have a new data access layer, we also need a new repository. Right? Exactly! Since we…

Keep reading

Dependency Injection to The Core (Part - I)

Okay since I’m writing blogs mostly on asp.net core lately, you might be wondering that why am I writing a blog on a topic which is already available in asp.net core official documentation. Well, in this post I’m not only going to talk about how you can achieve DI (Dependency Injection) in .net core but will also discuss about DI itself (what, why and how). This article reflects how I actually learned (still learning) DI. So, if you don’t want to follow my approach or…

Keep reading

Don't Share Your Secrets! (.NET CORE Secret Manager Tool)

I’ve been working on this million-dollar project of mine and wanted it to make the project open source. So, I made a repository on github and pushed my project. That’s where I almost made a big mistake. Since my project was data driven so there were some connection strings stuff in my web.config file, Practically I would remove the connection strings and other credentials stuff out of my web.config file before I push it to the repository. But it was a big headache for me since…

Keep reading

Building Apps with Polymer and ASP.NET CORE (Part - III)

We were done with the API creation part in the previous post. Let’s finish up the app by connecting the simple-todo component with those APIs. Basically we need to call our APIs to do that. We are going to do that with a Polymer component called iron-ajax. It makes Ajax easier to work with. So, just like what we did for every third party components lets install iron-ajax with Bower. Then add it to the header section of your HTML document. Here is the command to install iron-ajax bower…

Keep reading

Building Apps with Polymer and ASP.NET CORE (Part - II)

OK! As I told you in the previous post that I will make APIs using ASP.NET CORE Web API to be able to Add, Update, Edit and Delete todo items on the server side but the good news is ASP.NET CORE documentation already has an article on that. Here is the link, https://docs.asp.net/en/latest/tutorials/first-web-api.html Wait a minute! That doesn’t mean I’m not going to do anything in this post. If you went through that article already then you may…

Keep reading