Can I use EF Core with immutable object?
See original GitHub issueCan I use EF 7 with immutable object with read-only properties and without parameter less constructor? As example:
public class User
{
public User(int id, string name)
{
Id = id;
Name = name;
}
public int Id { get; }
public string Name { get; }
}
Issue Analytics
- State:
- Created 8 years ago
- Reactions:5
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Immutability and Entity Framework Core | by João Simões
But I'm going to explain how you can use immutable entities directly with Entity Framework Core so you know that not only it...
Read more >Immutable entities and value objects in EF Core! - Fati Iseni
We won't dive into all the pros and cons of adopting the immutability, which will require a separate article. We'll only demonstrate how...
Read more >Implementing value objects
Value object implementation in C# Having no ID field in a class to be used by Entity Framework (EF) was not possible until...
Read more >How to use immutable objects in ASP.NET Core MVC 5
To work with immutable collections, you should install the System.Collection.Immutable NuGet package in your project. You can read more about ...
Read more >Should We Use Records With EF Core as Model Classes?
We have learned that because of immutability, records are not best suited for use as model classes. Instead, we can use them as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@divega #10703 is the 2.1 issue. However, your points about allowing replacing immutable instances with new instances is very interesting. I think we should leave this issue on the backlog to cover that–could allow store-generated keys too–and leave #10703 to be specifically about the constructor support.
Triage: filed #11457 to cover updates to immutable entities. Closing this as a duplicate of #10703.