dotnet / dotnet/efcore

Version 9.0.0-preview.7.24405.3 cannot Create Compiled Model for Property string Source {get; set;}

Open
#34,493 1 comment 0 reactions 1 assignee Claimed by @AndriySvyryd View on GitHub
area-aot area-model-building customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

Version 9.0.0-preview.7.24405.3 cannot Create Compiled Model for Property `public string Source {get; set;}`

Simplified Entity Type (without annotation).
```
public partial class LoginLog
{
public string Id {get; set;}
public string Source {get; set;}
public string ProgrammVersion {get; set;}
public string? Protokoll {get; set;}
public System.DateTime Datum {get; set;}
public bool Geloescht {get; set;}
public System.DateTime ModDte {get; set;}
public string ModUser {get; set;}
}
```
Generated Annotation

```
......
public static void CreateAnnotations(RuntimeEntityType runtimeEntityType)
{
var id = runtimeEntityType.FindProperty("Id")!;
var datum = runtimeEntityType.FindProperty("Datum")!;
var geloescht = runtimeEntityType.FindProperty("Geloescht")!;
var modDte = runtimeEntityType.FindProperty("ModDte")!;
var modUser = runtimeEntityType.FindProperty("ModUser")!;
var programmVersion = runtimeEntityType.FindProperty("ProgrammVersion")!;
var protokoll = runtimeEntityType.FindProperty("Protokoll")!;
var source = runtimeEntityType.FindProperty("Source")!;
var key = runtimeEntityType.FindKey(new[] { id });
key.SetPrincipalKeyValueFactory(KeyValueFactoryFactory.CreateSimpleNullableFactory(key));
key.SetIdentityMapFactory(IdentityMapFactoryFactory.CreateFactory(key));
runtimeEntityType.SetOriginalValuesFactory(
ISnapshot (InternalEntityEntry source) =>
{
var entity5 = ((LoginLog)(source.Entity));
return ((ISnapshot)(new Snapshot((source.GetCurrentValue(id) == null ? null : ((ValueComparer)(((IProperty)id).GetValueComparer())).Snapshot(source.GetCurrentValue(id))), ((ValueComparer)(((IProperty)datum).GetValueComparer())).Snapshot(source.GetCurrentValue(datum)), ((ValueComparer)(((IProperty)geloescht).GetValueComparer())).Snapshot(source.GetCurrentValue(geloescht)), ((ValueComparer)(((IProperty)modDte).GetValueComparer())).Snapshot(source.GetCurrentValue(modDte)), (source.GetCurrentValue(modUser) == null ? null : ((ValueComparer)(((IProperty)modUser).GetValueComparer())).Snapshot(source.GetCurrentValue(modUser))), (source.GetCurrentValue(programmVersion) == null ? null : ((ValueComparer)(((IProperty)programmVersion).GetValueComparer())).Snapshot(source.GetCurrentValue(programmVersion))), (source.GetCurrentValue(protokoll) == null ? null : ((ValueComparer)(((IProperty)protokoll).GetValueComparer())).Snapshot(source.GetCurrentValue(protokoll))), (source.GetCurrentValue(source) == null ? null : ((ValueComparer)(((IProperty)source).GetValueComparer())).Snapshot(source.GetCurrentValue(source))))));
});

.....
```

because the property is named source and the parameter of SetoriginalValuesFactory too it doesn't compile because the source parameter from SetOriginalValuesFactory hides the source Property.

Workaround: rename the `var source = .....` to for example `var sourceProp = ....`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.