EF Code First migrations extensibility RRS feed

  • Question

  • There are some extensibility points in EF Code First migrations.

    In Migrations.Configuration I can set the SqlGenerator:

    SetSqlGenerator("System.Data.SqlClient"new CustomizedSqlGenerator());

    I can derive from SqlServerMigrationSqlGenerator and override methods.

    I can make new operations derived from MigrationOperation - but the DbMigration base class doesn't allow you to add them to it's internal list (AddOperation is internal)

    A class derived from SqlServerMigrationSqlGenerator will not recognize additional operations (the Generate(IEnumerable<MigrationOperation>) reflects against it's own Generate methods, not derived ones, apparently). I could create a completely custom MigrationSqlGenerator, but I still couldn't get the operations from the migration.

    I can just write Sql strings in the DbMigration, but it would be nicer to use more structured and potentially database agnostic MigrationOperations.

    1. Could the DbMigration.AddOperation be made public (with the caveat that it won't do anything without the supporting MigrationSqlGenerator).

    2. Could the SqlServerMigrationSqlGenerator.Generate(IEnumerable<MigrationOperation>) method be revised to look for any supporting Generate(MigrationOperation) - or some other extensibility point where I can plug in new MigrationOperations?

    Tuesday, March 13, 2012 8:41 AM

All replies

  • Hi martin,


    We will do some more pending research  about your problem and come back as
    soon as possible, Thanks for understanding.

    Have a nice day.

    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 14, 2012 1:25 PM
  • Hi Martin,

    You are correct that Migrations is not yet fully extensible in all the ways you described.

    This is good feedback. I have provided your feedback internally. Perhaps you would like to submit the idea at our Connect site as well?  http://connect.microsoft.com

    Cathy Miller

    Friday, March 16, 2012 8:06 PM