efcore icon indicating copy to clipboard operation
efcore copied to clipboard

error when scaffolding annotations : current CSharpHelper cannot scaffold literals of type 'System.String'

Open swaggerloaf opened this issue 11 years ago • 1 comments

dnx : 1.0.0-beta4-11337 clr x86 ef : 7.0.0-beta4-12679 Windows 8.1

The error seems to occur when trying to scaffold annotations during add migration

c:\projects\2015\NeoSample-ASPNET5\src\NeoSample>k ef migration add CreateIdentitySchema -c NeoSample.DbContexts.ApplicationDbContext
Using context 'ApplicationDbContext'.
info    : [Microsoft.Framework.DependencyInjection.DataProtectionServices] User profile is available. Using 'C:\Users\Glenn\AppData\Local\ASP.NET\DataProtection-Keys' as key reposi
tory and Windows DPAPI to encrypt keys at rest.
System.InvalidOperationException: The current CSharpHelper cannot scaffold literals of type 'System.String'. Configure your services to use one that can.
   at Microsoft.Data.Entity.Commands.Utilities.CSharpHelper.Literal(Object value)
   at Microsoft.Data.Entity.Commands.Migrations.CSharpModelGenerator.GenerateAnnotation(IAnnotation annotation, IndentedStringBuilder stringBuilder)
   at Microsoft.Data.Entity.Commands.Migrations.CSharpModelGenerator.GenerateAnnotations(IReadOnlyList`1 annotations, IndentedStringBuilder stringBuilder)
   at Microsoft.Data.Entity.Commands.Migrations.CSharpModelGenerator.Generate(IModel model, IndentedStringBuilder stringBuilder)
   at Microsoft.Data.Entity.Commands.Migrations.CSharpMigrationGenerator.GenerateMetadata(String migrationNamespace, Type contextType, String migrationName, String migrationId, Str
ing productVersion, IModel targetModel)
   at Microsoft.Data.Entity.Commands.Migrations.MigrationScaffolder.ScaffoldMigration(String migrationName, String rootNamespace)
   at Microsoft.Data.Entity.Commands.MigrationTool.AddMigration(String migrationName, String contextTypeName, String rootNamespace, String projectDir)
   at Microsoft.Data.Entity.Commands.Program.<>c__DisplayClass9_0.b__1()
   at Microsoft.Data.Entity.Commands.Program.ExecuteInDirectory(String startupProject, Func`1 invoke)
   at Microsoft.Data.Entity.Commands.Program.AddMigration(String name, String context, String startupProject)
   at Microsoft.Data.Entity.Commands.Program.<>c__DisplayClass7_1.
b__6() at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute(String[] args) at Microsoft.Data.Entity.Commands.Program.Main(String[] args)

swaggerloaf avatar Mar 23 '15 19:03 swaggerloaf

Now that annotation values are of type object (changed in 43e9ae89857859801325fab849d43e179232d3d3), we'll need to update the invocation to use dynamic.

bricelam avatar Mar 24 '15 17:03 bricelam