Skip to content

Extract IIdentifiable and annotation attributes (Attr, HasOne, etc.) into separate package #730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ikirkpat opened this issue May 1, 2020 · 7 comments · Fixed by #1127
Closed

Comments

@ikirkpat
Copy link

ikirkpat commented May 1, 2020

Description

Forgive me if this is a duplicate request but I couldn't find an answer...

We have a set of models that we're moving to an external package for other non-JADNC projects to use. They were originally in our JADNC app and had JADNC schema attributes on them (IIdentifiable, Attr, HasOne, etc...). We need to be able to apply a JADNC schema on them from our JADNC app while they live in another project that does not reference JADNC.

If there already is a solution, would someone point me to it?

I know EFCore solves this by providing their Fluent Api. Something like this would be a huge help in helping us decouple our models from the infrastructure layer of JADNC.

We are using JADNC 3.1 with .NET core 2.1

@bart-degreed
Copy link
Contributor

This was discussed a while ago here.

@bart-degreed
Copy link
Contributor

Related to #661.

@bart-degreed
Copy link
Contributor

bart-degreed commented May 28, 2020

Unfortunately there is currently no way to accomplish this. A fluent API is being added in #771 (design at #776), but even with that in place, you'd still need to reference JADNC because all resources need to implement IIdentifiable.

To accomplish what you want, we'd need to extract IIdentifiable, Attr, HasOne etc. into a separate NuGet package, which you can then reference from your models project (instead of the full JADNC package).

@yaniv-yechezkel
Copy link

The #771 PR takes care of mapping attributes fluently, and replaces the need for Annotations, in order to keep the Domain clean.

I don't really have an issue with referencing JADNC from the Domain, as I do so with Fluent NHibernate or EF where I end up placing Mappings/Configurations in the same assembly as the Domain.

My main concern are the Annotations, which I wanted to remove.

As for IIdentifiable, for most Domain implementations you already have concepts like Entity and Value Object, and Entity also have the concept of Id.
I've seen I can implement IIdentifiable explicitly on the Entity so the JADNC can use StringId at runtime, and it looks fine.

In order to eliminate the need to implement IIdentifiable, and accomplish this using fluent mapping, in a similar way of mapping a property, it will require more drastic change in both discovery during graph building, and in controller's implementations.

@bart-degreed
Copy link
Contributor

I've seen I can implement IIdentifiable explicitly on the Entity so the JADNC can use StringId at runtime, and it looks fine.

Yes, this works, as long as all your resources also have a typed Id property. There's some reflection code that depends on it.

@bart-degreed
Copy link
Contributor

For future reference, how to produce multiple dependent nuget packages from a single git repository is described at https://markheath.net/post/multiple-nuget-single-repo.

@bart-degreed bart-degreed added this to the Future milestone Sep 22, 2020
@bart-degreed
Copy link
Contributor

bart-degreed commented Jan 29, 2021

Marked as 'breaking' because we'll need to remove [NotMapped] from Identifiable and come up with a different approach.

@bart-degreed bart-degreed changed the title Add schema modifications from outside the model Extract IIdentifiable and annotation attributes (Attr, HasOne, etc.) into separate package Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants