I am working through a (simple) Entity Framework example in a Console Application just to learn the basics of Database Migrations in EF. All of the other Tables and Columns are being generated fine but this one Column is being created with angle brackets around it in SQL Server Express ( '[Content]' rather than 'Content').
I can't see any thing in the class declaration
public class Post
{
public int PostID { get; set; }
[MaxLength(200)]
public string Title { get; set; }
public string Content { get; set; }
public int BlogID { get; set; }
public Blog Blog { get; set; }
}
the Migration file
public partial class AddPostClass : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.Posts",
c => new
{
PostID = c.Int(nullable: false, identity: true),
Title = c.String(maxLength: 200),
Content = c.String(),
BlogID = c.Int(nullable: false),
})
.PrimaryKey(t => t.PostID)
.ForeignKey("dbo.Blogs", t => t.BlogID, cascadeDelete: true)
.Index(t => t.BlogID)
.Index(p => p.Title, unique: true);
AddColumn("dbo.Blogs", "rating", c => c.Int(nullable: false));
}
public override void Down()
{
DropForeignKey("dbo.Posts", "BlogID", "dbo.Blogs");
DropIndex("dbo.Posts", new[] { "Title" });
DropIndex("dbo.Posts", new[] { "BlogID" });
DropColumn("dbo.Blogs", "rating");
DropTable("dbo.Posts");
}
}
or in the generated SQL script (I used the -Verbose flag)
CREATE TABLE [dbo].[Posts] (
[PostID] [int] NOT NULL IDENTITY,
[Title] [nvarchar](200),
[Content] [nvarchar](max),
[BlogID] [int] NOT NULL,
CONSTRAINT [PK_dbo.Posts] PRIMARY KEY ([PostID])
)
which would indicate why this particular column is being generated with the angle brackets included?
Can anyone help?