# Migrating to 1.1

Version 1.1.0 of the Npgsql Entity Framework Core provider has been released and is available on nuget. This version works with version 1.1.0 of Entity Framework Core, and contains some new Npgsql features as well. Note that if you're using the command-line tools, you'll have to modify your tools section as described in the EF Core release post:

    "tools": {
      "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final"
    },

## New Features

Aside from general EF Core features, version 1.1.0 of the Npgsql provider contains the following:

- Hilo key generation (#5). This can be a much more efficient way to generate autoincrement key values.
- PostgreSQL array mapping (#15). This allows you to have plain CLR arrays on your entities, and have those arrays mapped to native PostgreSQL array columns.
- Optimistic concurrency with PostgreSQL's xmin column (#19). Simply specify `.UseXminAsConcurrencyToken()` on an entity to start using this, see the EF docs for more details.
- Cleanup of how serial (autoincrement) and generated GUID/UUID columns are managed.

Here's the full list of issues. Please report any problems to https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL.

## Upgrading from 1.0.x

If you've used 1.0.x without migrations, you can simply upgrade and everything should just work. Unfortunately, if you already have migrations from 1.0.x you'll have to do some manual fixups because of some bad decisions that were previously made. If deleting your old migrations and starting over (e.g. non-production database) is an option, you may wish to do so. The following are instructions for fixing up 1.0.x migrations.

First, Npgsql 1.0.x used a problematic method to identify serial (autoincrement) columns in migrations. If you look at your migration code you'll see `.Annotation("Npgsql:ValueGeneratedOnAdd", true)` on various columns. Unfortunately this annotation is also present on non-serial columns, e.g. columns with default values. This causes various issues and has been replaced in 1.1. However, you'll have to manually remove `.Annotation("Npgsql:ValueGeneratedOnAdd", true)`, and replace it with `.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)` but only on columns which should be serial (e.g. not on columns with defaults). If you attempt to run a migration that has the old annotation, Npgsql will throw an exception and refuse to run your migrations.

Unfortunately, this change will cause some incorrect changes the first time you add a migration after the upgrade. To avoid this, simply add a dummy migration right after upgrading to 1.1 and then delete the two new files generated for the dummy migration, but keep the changes made to your ModelSnapshot.cs. From this point on everything should be fine. Make sure you have no pending changes to your model before doing this!.

Apologies for this problematic upgrade procedure, it should at least keep things clean going forward.

## Contributors

Thank you very much to the following people who have contributed to the individual 1.1.x. releases.

### Milestone 1.1.1

Contributor | Assigned issues
--- | ---
@roji | 8

### Milestone 1.1.0

Contributor | Assigned issues
--- | ---
@roji | 11