Skip to content

Commit cbf8517

Browse files
committed
Add designTime parameter to IRelationalAnnotationProvider
Remove more design-time metadata from runtime model Fix some configuration loss when reattaching entity types Add missing SqlServer Metadata methods Add more tests
1 parent 7d2eb30 commit cbf8517

File tree

85 files changed

+4505
-1422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+4505
-1422
lines changed

src/EFCore.Design/Design/DesignTimeServiceCollectionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static IServiceCollection AddEntityFrameworkDesignTimeServices(
5858
.TryAddSingleton<IMigrationsCodeGeneratorSelector, MigrationsCodeGeneratorSelector>()
5959
.TryAddSingleton<IModelCodeGenerator, CSharpModelGenerator>()
6060
.TryAddSingleton<IModelCodeGeneratorSelector, ModelCodeGeneratorSelector>()
61-
.TryAddSingleton<ICompiledModelCodeGenerator, CSharpSlimModelCodeGenerator>()
61+
.TryAddSingleton<ICompiledModelCodeGenerator, CSharpRuntimeModelCodeGenerator>()
6262
.TryAddSingleton<ICompiledModelCodeGeneratorSelector, CompiledModelCodeGeneratorSelector>()
6363
.TryAddSingleton<INamedConnectionStringResolver>(
6464
new DesignTimeConnectionStringResolver(applicationServiceProviderAccessor))

src/EFCore.Design/Design/Internal/CSharpHelper.cs

+15-5
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ namespace Microsoft.EntityFrameworkCore.Design.Internal
2424
/// </summary>
2525
public class CSharpHelper : ICSharpHelper
2626
{
27-
private readonly IRelationalTypeMappingSource _relationalTypeMappingSource;
27+
private readonly ITypeMappingSource _typeMappingSource;
2828

2929
/// <summary>
3030
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
3131
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
3232
/// any release. You should only use it directly in your code with extreme caution and knowing that
3333
/// doing so can result in application failures when updating to a new Entity Framework Core release.
3434
/// </summary>
35-
public CSharpHelper(IRelationalTypeMappingSource relationalTypeMappingSource)
35+
public CSharpHelper(ITypeMappingSource typeMappingSource)
3636
{
37-
_relationalTypeMappingSource = relationalTypeMappingSource;
37+
_typeMappingSource = typeMappingSource;
3838
}
3939

4040
private static readonly IReadOnlyCollection<string> _keywords = new[]
@@ -267,8 +267,13 @@ private static StringBuilder ChangeFirstLetterCase(StringBuilder builder, bool c
267267
}
268268

269269
var first = builder[index: 0];
270+
if (char.IsUpper(first) == capitalize)
271+
{
272+
return builder;
273+
}
274+
270275
builder.Remove(startIndex: 0, length: 1)
271-
.Insert(index: 0, value: capitalize ? char.ToUpper(first) : char.ToLower(first));
276+
.Insert(index: 0, value: capitalize ? char.ToUpperInvariant(first) : char.ToLowerInvariant(first));
272277

273278
return builder;
274279
}
@@ -788,12 +793,17 @@ public virtual string UnknownLiteral(object? value)
788793
return Literal(enumValue);
789794
}
790795

796+
if (value is Type type)
797+
{
798+
return Literal(type);
799+
}
800+
791801
if (value is Array array)
792802
{
793803
return Array(literalType.GetElementType()!, array);
794804
}
795805

796-
var mapping = _relationalTypeMappingSource.FindMapping(literalType);
806+
var mapping = _typeMappingSource.FindMapping(literalType);
797807
if (mapping != null)
798808
{
799809
var builder = new StringBuilder();

src/EFCore.Design/Properties/DesignStrings.Designer.cs

+20-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/EFCore.Design/Properties/DesignStrings.resx

+5-5
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
<value>Could not find type mapping for column '{columnName}' with data type '{dateType}'. Skipping column.</value>
134134
</data>
135135
<data name="CompiledModelConstructorBinding" xml:space="preserve">
136-
<value>The entity type '{entityType}' has a custom constructor binding. This is usually caused by using proxies. Compiled model can't be generated, because custom constructor bindings are not supported.</value>
136+
<value>The entity type '{entityType}' has a custom constructor binding. This is usually caused by using proxies. Compiled model can't be generated, because dynamic proxy types are not supported. If you are not using proxies configure the custom constructor binding in '{customize}' in a partial '{className}' class instead.</value>
137137
</data>
138138
<data name="CompiledModelDefiningQuery" xml:space="preserve">
139139
<value>The entity type '{entityType}' has a defining query configured. Compiled model can't be generated, because defining queries are not supported.</value>
@@ -142,16 +142,16 @@
142142
<value>The entity type '{entityType}' has a query filter configured. Compiled model can't be generated, because query filters are not supported.</value>
143143
</data>
144144
<data name="CompiledModelTypeMapping" xml:space="preserve">
145-
<value>The property '{entityType}.{property}' has a custom type mapping configured. Compiled model can't be generated, because custom type mappings are not supported.</value>
145+
<value>The property '{entityType}.{property}' has a custom type mapping configured. Configure it in '{customize}' in a partial '{className}' class instead.</value>
146146
</data>
147147
<data name="CompiledModelValueComparer" xml:space="preserve">
148-
<value>The property '{entityType}.{property}' has a value comparer configured. Compiled model can't be generated, because value comparers are not supported.</value>
148+
<value>The property '{entityType}.{property}' has a value comparer configured. Use '{method}' to configure the value comparer type.</value>
149149
</data>
150150
<data name="CompiledModelValueConverter" xml:space="preserve">
151-
<value>The property '{entityType}.{property}' has a value converter configured. Compiled model can't be generated, because value converters are not supported.</value>
151+
<value>The property '{entityType}.{property}' has a value converter configured. Use '{method}' to configure the value converter type.</value>
152152
</data>
153153
<data name="CompiledModelValueGenerator" xml:space="preserve">
154-
<value>The property '{entityType}.{property}' has a value generator configured. Compiled model can't be generated, because value generators are not supported.</value>
154+
<value>The property '{entityType}.{property}' has a value generator configured. Use '{method}' to configure the value generator factory type.</value>
155155
</data>
156156
<data name="ConflictingContextAndMigrationName" xml:space="preserve">
157157
<value>The name you have chosen for the migration, '{name}', is the same as the context class name. Please choose a different name for your migration. Might we suggest 'InitialCreate' for your first migration?</value>

0 commit comments

Comments
 (0)