How to pass parameters to DbMigration.Sql() Method

c#, entity-framework, entity-framework-migrations, syntax

Solution

I dug into the EF source code and it seems that this parameter (or rather the `MigrationOperation.AnonymousObject` property that's created from it) is not used at all!

I've created a ticket on their issue tracker to either do something about it or remove the api

Problem

When using Entity Framework Migrations, the `DbMigration` base class has a Sql method which takes parameters in an anonymous object I cannot for the life of me figure out how to use it. ``` Sql(@" UPDATE dbo.SlideSets SET Name = @Name, ", false, new { Name = "Foo" } ); ``` Results in the error ``` System.Data.SqlClient.SqlException (0x80131904): Must declare the scalar variable "@Name" ``` What's the correct syntax of this statement?

Original source