You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Custom Migration Operations shows incorrect way to get type mapping source for string #4768
Using a MigrationOperation shows the following code
publicclassMyMigrationsSqlGenerator:SqlServerMigrationsSqlGenerator{publicMyMigrationsSqlGenerator(MigrationsSqlGeneratorDependenciesdependencies,ICommandBatchPreparercommandBatchPreparer):base(dependencies,commandBatchPreparer){}protectedoverridevoidGenerate(MigrationOperationoperation,IModelmodel,MigrationCommandListBuilderbuilder){if(operationisCreateUserOperationcreateUserOperation){Generate(createUserOperation,builder);}else{base.Generate(operation,model,builder);}}privatevoidGenerate(CreateUserOperationoperation,MigrationCommandListBuilderbuilder){varsqlHelper=Dependencies.SqlGenerationHelper;varstringMapping=Dependencies.TypeMappingSource.FindMapping(typeof(string));// <--------------------------builder.Append("CREATE USER ").Append(sqlHelper.DelimitIdentifier(operation.Name)).Append(" WITH PASSWORD = ").Append(stringMapping.GenerateSqlLiteral(operation.Password)).AppendLine(sqlHelper.StatementTerminator).EndCommand();}}
The marked line returns null.
The CLR Type mappings simply don't contain a string type key
I am unable to find the right way of getting a string type mapping.
Activity
Expand and clarify migrations guidance. (dotnet#5445)