Skip to content

Commit

Permalink
Also embed the "Source" resource when it's availlable
Browse files Browse the repository at this point in the history
  • Loading branch information
mrahhal committed Oct 11, 2016
1 parent 9902885 commit 8204b0b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Migrator.EF6.Tools/Executor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,19 @@ public void AddMigration(string name, string outputDir, bool ignoreChanges)
File.WriteAllText(Combine(migrationsDir, migration.MigrationId + ".cs"), migration.UserCode);

// Write needed resource values directly inside the designer code file.
// Apparently, aspnet and resource files don't play well (or more specifically,
// the way ef6 migration generator is interacting with the resources system)
// It'll be a pain to ask the users to embed the resources from project.json.
var targetValue = migration.Resources["Target"];
var designerCode = migration.DesignerCode
.Replace("Resources.GetString(\"Target\")", $"\"{targetValue}\"");

var sourceObject = default(object);
if (migration.Resources.TryGetValue("Source", out sourceObject))
{
var sourceValue = sourceObject as string;
designerCode = designerCode
.Replace("Resources.GetString(\"Source\")", $"\"{sourceValue}\"");
}

// Write the designer code file.
File.WriteAllText(Path.Combine(migrationsDir, migration.MigrationId + ".Designer.cs"), designerCode);
}
Expand Down

0 comments on commit 8204b0b

Please sign in to comment.