EF Core 8 Finally Fixes Value Objects

EF Core 8 Finally Fixes Value Objects

Milan Jovanović

9 месяцев назад

24,450 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@JordiLC9502
@JordiLC9502 - 26.01.2024 23:17

Hi Milan, do you achieve that complex property works with typed ID, like BookId(Guid ID)?

Ответить
@ArcaneEye
@ArcaneEye - 21.12.2023 18:33

Quick question re: list of complex types. If a complex type is mapped to columns in a table alongside the entity they belong to, how would you map a list of those to the table? Isn't that exactly what navigation properties are for?

Ответить
@JordiAragonZaragoza
@JordiAragonZaragoza - 16.11.2023 15:46

It's not yet full supported. Complex type collection support is not ready. Check the issue 31237 and vote!

Ответить
@gorgestv6340
@gorgestv6340 - 05.10.2023 14:07

I don't understand what is the meaning of the Owned types

Ответить
@wmalgoire
@wmalgoire - 04.10.2023 01:09

I feel bad for people getting obsessed by the business domain trivial example and not trying to understand this new feature.. Maybe you should post a video on active listening Milan 😂😂

I mean, there are other great contents on value objects use cases and benefits.

Having struggled with poor implementations and complexity of value object persistence in efcore, I'm quite excited by this new feature! Even if in the meantime we'll have to handle collections manually..but that's a good step forward and I'll use this for sure 😊

All in all, another handy feature to keep in our toolbelt 👍

Thanks for your hard work Milan 🙏

Ответить
@techpc5453
@techpc5453 - 03.10.2023 20:38

Ответить
@EzequielRegaldo
@EzequielRegaldo - 02.10.2023 18:09

Its AWESOME ! thank you so much for your content <3

Ответить
@greensporevalley
@greensporevalley - 02.10.2023 00:58

.NET stare

Ответить
@vincentcifello4435
@vincentcifello4435 - 01.10.2023 03:50

It's not coupling if you call it a "Value Object"

There is no Id if EF Core hides it from you.

Right?

There is no such thing as a "Value Object" . If it is stored in ANY type of database and gets retrieved, then it has an associated Id. Period. This is definitional. Arthur Vickers effectively said this in an EF Core stand up.

Nothing was "fixed". Coupling and magical thinking were enabled.

Stop the madness, Milan.

Ответить
@joebyrne7343
@joebyrne7343 - 01.10.2023 00:58

Must the columns be author_? Can this be implemented in db first scenario where the existing columns may not follow that naming convention?

Ответить
@_IGORzysko
@_IGORzysko - 30.09.2023 23:49

Thanks for the video Milan! The possibility o fetching only value object data from the table is really great 🔥

Are EF 8 value objects tracked the same as "entity" entities? 🤔

Ответить
@silvertek
@silvertek - 30.09.2023 20:14

Will this avoid the exception when using stringly typed ids since we use them as both value/nonentity types for the aggregate but as entity types when we reference them from another aggregate?

Ответить
@xiovaii
@xiovaii - 30.09.2023 11:39

Finally!

Ответить
@jeroen7362
@jeroen7362 - 30.09.2023 10:35

I do not see the point. what does this solve? Why not have two real classes and tables? In real life an author writes 1 or more books. Why would you store the author multiple times? My advise is to not use any magic in EF core. Also implicit many2many tables that can be created by EF. Just write your own many2many class, you can then for instance put the timestamp and userid on it, who added that connection. Your are then in full control of everything.

Ответить
@user-gk4om7po4p
@user-gk4om7po4p - 30.09.2023 08:31

awesome

Ответить
@Sander-Brilman
@Sander-Brilman - 30.09.2023 01:17

how would collections work with complex types? shouldnt a new table be added for that since not all db providers support the array type

Ответить
@MikyShooter
@MikyShooter - 29.09.2023 23:55

For all that says this example does not suit the feature, you may be right. It doesn't metter but the explication, that was imo exaustive.

Here is another simple example:
In case of an order we may have a shipping address related to it. It's not ideal to save the Id of the customer address but the information itself at time t.
This because the address could potentially be removed from the customer entity, or even modified. Best thing is to store it separately, as this case, in a complex object, also to sepate concerns in class.

Thank you Milan for all your videos.

Ответить
@damiannizio4039
@damiannizio4039 - 29.09.2023 23:37

Couldn't you just have simply used conversion before?
IE:
builder.Property(x => x.SomeProperty).HasConversion(x => x.Value, x => new ValueObject(x));

Ответить
@reelleer
@reelleer - 29.09.2023 19:09

Dicha funcionalidad existía en EF 6, por lo tanto ver que EF Core 8 ya la tiene me motiva a migrar mi aplicación "legacy".

Ответить
@rusektor
@rusektor - 29.09.2023 18:55

Doesn't this remind [ComplextType] attribute in EF 4.0?

Ответить
@kennyhendricks4293
@kennyhendricks4293 - 29.09.2023 18:24

I am glad that this has been fixed

Ответить
@astralpowers
@astralpowers - 29.09.2023 18:09

Collections for value objects would really be useful for my use case

Ответить
@phugia963
@phugia963 - 29.09.2023 15:27

finally we can have a good EF features to support define & map value object to the database 😄

Ответить
@nicolasL009
@nicolasL009 - 29.09.2023 15:21

Very informative video! Too bad it'll take a while before I get to use EFCore 8 at my current job. Stubbled upon the issues mentioned in the video quite a few times with older EF versions. Keep up the good work :)

Ответить
@nick_stelmakh
@nick_stelmakh - 29.09.2023 15:17

the poor example. didn’t show all wide spectrum of this update

Ответить
@vasiliylu8054
@vasiliylu8054 - 29.09.2023 15:09

Thanks! It's very cool feature

Ответить
@kis.stupid
@kis.stupid - 29.09.2023 15:08

I believe you but I don't understand why that errored before? Because of the reference? It has no PK. I did notice seeding those owned types needed to be initialized as anonymous types.
I think you could use Records as well, that brings along other complications ofc.
I would like to learn more about those "nvarchar(max)", how to globally limit that, if you should limit that. Or how optimized that is by default.

Ответить
@tonystoynev7969
@tonystoynev7969 - 29.09.2023 15:05

Hey, another great video! But I am not getting the point of having a collection of complex types inside the entity? How this collection will be mapped into the database?

Ответить
@user-rd4cd9zj1s
@user-rd4cd9zj1s - 29.09.2023 15:04

This is a very poor example of a Value Object. I think the feature might be useful in some scenarios, but this example is not one. It would be nice to see a real-world example instead.

Ответить
@antonmartyniuk
@antonmartyniuk - 29.09.2023 14:40

I like this feature much, hope collections will be supported too until EF 8 release

Ответить
@psdmaniac
@psdmaniac - 29.09.2023 14:28

I have never used that. Autors should be stored is diffrent table and reused (many to many).
This "own" thing looks like something against database normalization.

Ответить
@fandermill
@fandermill - 29.09.2023 14:16

Changing the last name of the author and updating it in all books does not make sense, as ValueObjects should be immutable (well, at least from a DDD perspective).
Nice feature demo though, I can't wait to clean up my dbcontext configurations.

Ответить
@gianlucalocri
@gianlucalocri - 29.09.2023 14:06

Finally!!! 🤩
Thanks Milan!

Ответить
@nasermasri9954
@nasermasri9954 - 29.09.2023 14:01

First!😅

Ответить