Coding

Quick Tip: Manually Run EF Migrations on External Databases

Entity Framework migrations are a great thing. They’ve made my development life a LOT easier. Automated migrations can cause problems, especially on a project with multiple developers involved. For that, we use manual migrations through the Package Manager Console.

But how do you manually run these migrations against your test (or live) server when your deployment tool doesn’t run them? If you have access to the database in question, you can add the ConnectionString and ProviderName parameters at the Package Manager Console prompt and make life a lot easier:

Update-Database -ConnectionString "MY_CONNECTION_STRING" -ConnectionProviderName "System.Data.SqlClient"

You can pull your connection string direct from your web.config transform, no special “magic” needed.

Enjoy! Continue reading “Quick Tip: Manually Run EF Migrations on External Databases”

Advertisements
Matrix Code Tunnel
Coding

Refactored: Creating dynamic/configurable parameterized queries in Entity Framework

A little while back I posted about a technique I was using to setup parameterized queries using Entity Framework. I had posted to the .Net group on Google+ and received some amazing feed back from Dan Nemec and Chris McCall and refactored the code. It’s cleaner, easier to work with, and hopefully a bit more optimized too. Here’s what’s different. Continue reading “Refactored: Creating dynamic/configurable parameterized queries in Entity Framework”

Computer Code
Coding

Creating dynamic/configurable parameterized queries in Entity Framework

EDIT: A better, refactored version of this can be found here.

Entity Framework is an amazing tool. It allows you to quickly and easily get your basic queries and updates running with little hassle. In addition, you have business objects to interact with, which makes your middle tier (or your controller) that much easier to work with. However, when you need to start setting up more dynamic queries from user input, things start to get tricky. Here’s a solution I created to help with that. Continue reading “Creating dynamic/configurable parameterized queries in Entity Framework”

Computer Code
Coding

Automatic User and Time Stamping in Entity Framework 4

Computer Code

Lately I’ve had the opportunity to really dig deep with Entity Framework 4. While I’m not utilizing the “Code First” approach, I’m still quite happy with now nice the Entity Model can take my existing database and build practically everything I need for my application’s data layer, and most of my business layer. The one tricky thing to resolve still is automating the user/time stamping that we use to track changes in the application. Continue reading “Automatic User and Time Stamping in Entity Framework 4”