Skip to main content
Home
Docs
Contact
Store
Blog
Forum
Register
Log in
Home
Forum
Using cloudscribe core models in custom features with EF Core
To ensure you get the best experience, this website uses cookies.
Learn More
Accept
Session Expiry
For your security, your session will time out in
seconds...
Using cloudscribe core models in custom features with EF Core
Delete
Edit
0
viewed
718
edited
posted
nirkbirk
Title
Body
I'm writing a custom feature for cloudscribe and have a question about what the best/cleanest way to incorporate cloudscribe Core models into mine is. Currently, I am adding the concept of user 'organisations' to my feature. The relationship is many users to one organisation. Normally, I'd just add an OrganisationId property to the SiteUser class, a List<SiteUser> to my Organisation class, and then define the relationship in the model builder, but obviously I'm setting up my organisation model from a different data context in a different project, and I don't want to modify cloudscribe core source. I've [found a post][1] that explains how to do something like this across data contexts in EF 6 (I assume it will work similarly in EF Core) but before I pursue this I wanted to know if there was a cleaner/better way to do this. I noticed that the SimpleContent projects don't seem to have references to users other than author names for blog posts (I may be missing something here though!) I also considered using the KVP package for users, but I really like the convenience and safety of using EF Core features for navigation properties and auto cascade nulling OrganisationId when an org is deleted for example. This question was originally posted on the Gitter chatroom and it was suggested that I create a junction table between my organisations and the cloudscribe users table. I can do this, will I then be able to have something like context.Organisations.Include(o => o.Users); and have EF handle the fetching of the users, despite the model being defined in a different context? Another suggestion was to use ado queries to manually join the tables. I could do this, but I'd really like to keep it simple and avoid manually writing SQL where possible. I'd also have to modify this code if new SiteUser properties were added in future versions of cloudscribe which hurts maintainability. Thanks [1]: https://www.dotnettricks.com/learn/entityframework/entity-framework-6-code-first-migrations-with-multiple-data-contexts
Preview
Tags
cloudscribe-core
Save
Cancel Edit
add a comment
add comment
Answers
Please enable javascript to use this feature.
Confirm Delete
×
Are you sure you want to delete the this Thread?
Insert Link
Upload a File
File uploads are not supported
Accepted file types: application/pdf,text/plain
Drop file here or click to browse device for file.
Browse Server
Insert Image
Drop file here or click to browse device for file.
Browse Server
Ask Question
Tags
azure
cloudscribe-core
custom-registration
file-manager
forms-and-surveys
forums
identityserver
membership
navigation
newsletter
pagination
pwakit
simple-content
talkabout-comments
themes