robconery/Manatee — pull request #10 by tawman (2011-12-05 20:21:04+00:00)
Title: Sample FK Migration Script: First Table - Second Table the Id column case sensitivity

On SQL Server the sample migration script causes a SqlException:

up
Migrating from 2 to 3
++ VERSION 3 Command:
ALTER TABLE SecondTable WITH NOCHECK ADD
CONSTRAINT [FK_SecondTable_FirstTable] FOREIGN KEY([firstTableID])
REFERENCES FirstTable ([ID]);

Unhandled Exception: System.Data.SqlClient.SqlException: Foreign key 'FK_SecondTable_FirstTable' references invalid column 'ID' in referenced table 'FirstTable'.
Could not create constraint. See previous errors.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Manatee.Migrator.Database.Execute(String query) in C:\@github\Manatee\Migrator.cs:line 44
at Manatee.Migrator.Migrate(Int32 to, Boolean execute) in C:\@github\Manatee\Migrator.cs:line 121
at VidPub.Tasks.Program.DecideWhatToDo(String command) in C:\@github\Manatee\Program.cs:line 95
at VidPub.Tasks.Program.DecideWhatToDo(String command) in C:\@github\Manatee\Program.cs:line 130
at VidPub.Tasks.Program.SayHello() in C:\@github\Manatee\Program.cs:line 176
at VidPub.Tasks.Program.Main(String[] args) in C:\@github\Manatee\Program.cs:line 26

____________________

USE [master]
GO

/****** Object: Database [manatee_dev] Script Date: 12/05/2011 11:37:55 ******/
CREATE DATABASE [manatee_dev] ON PRIMARY
( NAME = N'manatee_dev', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\manatee_dev.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'manatee_dev_log', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\manatee_dev_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO

ALTER DATABASE [manatee_dev] SET COMPATIBILITY_LEVEL = 100
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [manatee_dev].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [manatee_dev] SET ANSI_NULL_DEFAULT OFF
GO

ALTER DATABASE [manatee_dev] SET ANSI_NULLS OFF
GO

ALTER DATABASE [manatee_dev] SET ANSI_PADDING OFF
GO

ALTER DATABASE [manatee_dev] SET ANSI_WARNINGS OFF
GO

ALTER DATABASE [manatee_dev] SET ARITHABORT OFF
GO

ALTER DATABASE [manatee_dev] SET AUTO_CLOSE OFF
GO

ALTER DATABASE [manatee_dev] SET AUTO_CREATE_STATISTICS ON
GO

ALTER DATABASE [manatee_dev] SET AUTO_SHRINK OFF
GO

ALTER DATABASE [manatee_dev] SET AUTO_UPDATE_STATISTICS ON
GO

ALTER DATABASE [manatee_dev] SET CURSOR_CLOSE_ON_COMMIT OFF
GO

ALTER DATABASE [manatee_dev] SET CURSOR_DEFAULT GLOBAL
GO

ALTER DATABASE [manatee_dev] SET CONCAT_NULL_YIELDS_NULL OFF
GO

ALTER DATABASE [manatee_dev] SET NUMERIC_ROUNDABORT OFF
GO

ALTER DATABASE [manatee_dev] SET QUOTED_IDENTIFIER OFF
GO

ALTER DATABASE [manatee_dev] SET RECURSIVE_TRIGGERS OFF
GO

ALTER DATABASE [manatee_dev] SET DISABLE_BROKER
GO

ALTER DATABASE [manatee_dev] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO

ALTER DATABASE [manatee_dev] SET DATE_CORRELATION_OPTIMIZATION OFF
GO

ALTER DATABASE [manatee_dev] SET TRUSTWORTHY OFF
GO

ALTER DATABASE [manatee_dev] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO

ALTER DATABASE [manatee_dev] SET PARAMETERIZATION SIMPLE
GO

ALTER DATABASE [manatee_dev] SET READ_COMMITTED_SNAPSHOT OFF
GO

ALTER DATABASE [manatee_dev] SET HONOR_BROKER_PRIORITY OFF
GO

ALTER DATABASE [manatee_dev] SET READ_WRITE
GO

ALTER DATABASE [manatee_dev] SET RECOVERY SIMPLE
GO

ALTER DATABASE [manatee_dev] SET MULTI_USER
GO

ALTER DATABASE [manatee_dev] SET PAGE_VERIFY CHECKSUM
GO

ALTER DATABASE [manatee_dev] SET DB_CHAINING OFF
GO