Entity Framework Core Part 2

preview_player
Показать описание
In this episode, Robert is joined by Phil Japikse for part 2 of a 5 part series on Entity Framework Core. Aimed at folks new to EF Core, Phil shows how to start with an existing SQL Server database, create entities/objects for each table and then how to perform basic CRUD operations on the data.

Change Tracking is one of the most compelling reasons to use an object-relational-mapper (ORM) like EF Core. In this episode we discuss how the change tracker works, see it in action, as well as load data outside of the change tracker.

Episode list:

Part 2: Change Tracking (this episode).

Рекомендации по теме
Комментарии
Автор

Robert, thank you for asking/pausing with great questions. No disrespect to Phil's presentations, but clarification is very important.
Love to have you as the host.

BenHayat
Автор

I love the chemistry guys! 😂

Host: "Your code doesn't work and its my fault",
PJ: "Absolutely, but I can use the \"General Contractor\" term- unless you're just gonna take that back from me",
Host: "No Way!" 😎🧠🕊

Thanks y'all! Still trying to finish and understand, but the point about "code-centric" vs "code-first" was definitely a deterrent for a very long time, so kudos on mentioning that ✌

bbry
Автор

This is most helpful. I have learnt a lot about EF Core through practical use but there are gaps. This kind of video helps fill in those gaps. Great to hear that explicit use of FK in models is recommended. Looking forward to the rest of the series.

iancarr
Автор

These videos are gold! Why are there not more views?

pw.
Автор

3:36 I was hoping you guys talk about this.
Really nice content.
Thank you.

marcosoliveira
Автор

3:27 (for example). How are you making => into one character?

bradleyhodgins
Автор

"General Contractor" & " Code Centeric". Two perfect phrases, MSFT should use.

BenHayat
Автор

keep them coming, very good info and very clear.
The one thing I miss from EF Core is the Many to Many magic from EF 6, now we have to make an extra class just for that (even though EF 6 did that automatically, but only in the DB)

spyofborg
Автор

1:54 I would still prefer, Master Control Program, what is general contractor... it sounds bad

memd
Автор

Great stuff, keep it up... Really like the interaction and style.

doubleD_KDRD
Автор

What is the plugin which shows the inline type info for variables used?

serhanyengulalp
Автор

I insist... they should go from something basic, as not all people understand complex stuff, they should explain the scaffolding options they used... what exactly is DbentityEntry and so on... but thanks, the videos are awesome.

sipi
Автор

Hello Gents, what is it that you're trying to achieve? Not very clear, sorry

HiteshTulsaniAtGooglePlus
Автор

Hopefully some helpful stuff here:

I get the following when running after running the scaffolding command and running the ChangeTracking code:

SqlException: The DELETE statement conflicted with the REFERENCE constraint The conflict occurred in database "AdventureWorks", table "Person.EmailAddress", column 'BusinessEntityID'.

The statement has been terminated.


If I manually go into SQL Server Management Studio and manually turn on cascading deletes on relationships linked to Person, it deletes record #1 and then exceptions out on AddEntity on the next run if I wanted to actually add a record, because of some xml errors it wants more complete info before actually adding a Person.

Just a guess. The cascading deletes is maybe perhaps something that the scaffolding script tool needs to account for eventually so that it can make determinations whenever cascading foreign key deletes aren't turned on already on the indexes by default, because if you try to delete a Person record with dependency records in other tables you'll get an exception.

I also needed to run Database.SetTimeout(9000); on the constructor for options) or else I would get SQL timeout exceptions.

EditEntry just hangs for about 5 minutes or more on the context.SaveChanges(), on a reasonably fast i5 Dell laptop with SSD, LocalDB MSSQL Express. Finally updated after a few minutes, even changing to Release build and Ctrl-F5 in Visual Studio it takes some time.

AdventureWorks is maybe not the easiest usage of a database to show off simple CRUD features, maybe something like a simple ToDo list would be a good start. I tried this in MSSQL just making a simple ToDo database and table and referencing it with the scaffold tool and it works just fine, updates were near-instantaneous unlike AdventureWorks in my instance.

I ran into this same long time to add or update problem on another db/table on a MSSQL install some time ago that was only maybe about ~500 records, but had a lot of related fields. Is it an issue in the change tracker?

I would also maybe check the database too if you're updating property names, which is possibly why the field name updates in the video failed.

One more problem is that after EditEntity() the populates a result but its fields have IsModified set to false. I only get a population with changes if I grab them before _context.SaveChanges(); I built from NuGet as the scaffolding tool wouldn't let me use a GitHub build as it's looking for specific packages rather than universally looking for That's another area I think should maybe be modified. Something else is that because of identity inserts being off I couldn't just add and delete a record of a specific id, making a CRUD test a little less destructive.

I've been building a database system and want to write an EF Core provider for it and have been glancing over some docs, but there's little documentation out there about it, some of which is outdated already with .NET Core 3.1, is there a tool I can use to see what are the minimal classes I need to write a functional provider?

johnernest
Автор

if this was intended to be some sort of an EFCore presentation... Then this is a bad presentation

bitzartdev