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
System.InvalidOperationException: No suitable constructor was found for entity type 'Todo'. The following constructors had parameters that could not be bound to properties of the entity type:
Cannot bind 'id', 'title' in 'Todo(Guid id, string title)'
Note that only mapped properties can be bound to constructor parameters. Navigations to related entities, including references to owned types, cannot be bound.
If you put the [<CLIMutable>] attribute on (which compiles the record with mutable properties and a default ctor) then it works. However, this is non-obvious and normal records should "just work" with EF.
The text was updated successfully, but these errors were encountered:
Working with immutable types in EF is currently limited, since change tracking and updating rely on mutability (see #11457, this is regardless of F# or C#). Putting the above in the backlog to understand the F#-specific construction situation though.
Good news is that I think most F# people using EF would probably use it in a "disconnected" mode - without change tracking. For that mode, you don't really care about the immutable nature (in the same way that many other things like Json deserialization, Dapper etc. don't need it). I think simply being able to construct records would be a big win in and of itself.
The following record does not work in EF Core:
If you put the
[<CLIMutable>]
attribute on (which compiles the record with mutable properties and a default ctor) then it works. However, this is non-obvious and normal records should "just work" with EF.The text was updated successfully, but these errors were encountered: