Entity Framework Migrations: PrimaryKey
I have a POCO model for which the Primary Key property maps onto a column
with a different name.
The model is something like:
public class Transaction
{
public long Id { get; set; }
//....more props
}
So the migration looks something like:
CreateTable(
"dbo.dtlTransactions",
c => new
{
Id = c.Long(nullable: false, identity: true, name:
"intTransactionID"),
//...more cols
})
.PrimaryKey(t => t.Id);
When running the migration, however, I get:
System.Data.SqlClient.SqlException (0x80131904): Column name 'Id' does not
exist in the target table or view.
it seems as if the name property of the columnbuilder isn't utilised when
generating sql. The -verbose option on the migration gives me this sql:
CREATE TABLE [dbo].[dtlTransactions] (
[intTransactionID] [bigint] NOT NULL IDENTITY,
--...other cols
CONSTRAINT [PK_dbo.dtlTransactions] PRIMARY KEY ([Id])
Any ideas? Is this an obvious bug?
No comments:
Post a Comment