Skip to content
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

Deleting related entites without FK #97

Closed
Mats391 opened this issue Oct 28, 2016 · 5 comments
Closed

Deleting related entites without FK #97

Mats391 opened this issue Oct 28, 2016 · 5 comments
Assignees
Milestone

Comments

@Mats391
Copy link

Mats391 commented Oct 28, 2016

I am currently working on a MyIsam database and found some unexpected behavior when cascade deleting. I could switch to InnoDb or another engine that supports FK for dealing with this natively on the database, but I actually do not want to care about the database too much while working with EF.

The issue

On a database engine that does not support FK (e.g. MyIsam) related entities that should cascade on delete only get deleted if you eager load them before.
Example:

// This will delete related Students
db.Remove(course.Include(x=>x.Students);

// This will not delete related Students
db.Remove(course);

This could be an issue with EF core and 1.1 might actually fix this as they say 1.1 will deal with more queries on the database instead of memory. With 1.1 it also looks like we will be able to easily load related entities without having to do a lot of includes.
All in all would be nice if this could be done on the database without explicitly having to eager load everything.

@caleblloyd
Copy link
Contributor

Explicit Loading (commit, docs) is supported in EF 1.1.0-preview1.

@kagamine I think we should up our build to support 1.1.0-preview1, since we will end up shipping Pomelo 1.1 once EF 1.1 is RTM.

Lazy loading is still not supported.

@Mats391 you should always use InnoDB unless you have a very good reason to be using MyISAM. There's plenty of articles out there that explain the differences, but InnoDB will be far more stable for you.

@yukozh
Copy link
Member

yukozh commented Oct 29, 2016

Where is VS Tooling for .NET Core 1.1.0-prev1?

@caleblloyd
Copy link
Contributor

Not sure about VS Tooling, I use JetBrains Project Rider. The 1.1.0-preview1 dontet install instructions are here though: https://blogs.msdn.microsoft.com/dotnet/2016/10/25/announcing-net-core-1-1-preview-1/

@caleblloyd
Copy link
Contributor

I can't get command line tooing to work (same as VS tooling I think). Looks like there's an open issue:

dotnet/efcore#6897

I've got the upgrade to 1.1.0-preview1 WIP here: caleblloyd@0b5d1a6, once Microsoft fixes the tooling I will test it and open a PR

@caleblloyd
Copy link
Contributor

@Mats391 explicit loading is working in our 1.1.0-preview1 builds. For an example of how it works, checkout the Test Case . It doesn't cover bulk update/delete scenarios though.

dotnet/efcore#795 will bring bulk Update / Delete whenever it is implemented.

It looks like https://github.com/zzzprojects/EntityFramework-Plus may provide the extension methods that you need for Bulk Update / Delete, but I haven't tried it.

@yukozh yukozh added this to the 1.1.0 milestone Nov 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants