question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can I use EF Core with immutable object?

See original GitHub issue

Can 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:closed
  • Created 8 years ago
  • Reactions:5
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ajcvickerscommented, Mar 26, 2018

@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.

0reactions
ajcvickerscommented, Mar 28, 2018

Triage: filed #11457 to cover updates to immutable entities. Closing this as a duplicate of #10703.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found