551125 (2) [Avatar] Offline
#1
Hi Jon.
It took me a while to arrive at my first EF Core Migration, but finally it got it working. Now, I am looking to follow you along in several chapters of querying, but first I would like to seed the new Db with some data. After some research I found that this works not as easily as in EF6. Where is the code or the sql script to seed the new Db?
I don't want to write tons of query code without being able to apply it to the Db, right? I did find "CreateSpecialBook', but that is only one entity, I want 100 entities.
I have looked around in your GitHub site, but the chapter branches prevent me from any overview to perform a directed search based on an educated guess, so I cannot find this seeding code or script. Help me please.

Regards, Nick.
Jon P Smith (32) [Avatar] Offline
#2
Hi Nick,

Have a look at section 5.9.2. In there I talk about linking to a database in an ASP.NET Core application, and in listing 5.10 I talk about where to put your seed code and in listing 5.11 I show a simple seed code. Some more complex seeding code is in branches Chapter02 onwards and can be found in ServiceLayer.DatabaseServices.Concrete.SetupHelpers.cs.

I do have a book generator class for creating data for performance testing in all the Chapter13-??? branches. If you want to play with that its in ServiceLayer.DatabaseServices.Concrete.BookGenerator.cs. But be warned - its complex (for performance reasons) and I don't support it as its not mentioned in the book.

For an overview I suggest you select the branch of a high chapter, say branch Chapter12 (13 and 14 change things) and then look at the code. I build the code progressively, with the next chapter branching from the last chapter so you see the sum of all the changes. That might help.
551125 (2) [Avatar] Offline
#3
Hi Jon,

Thanks for the quick reply.
I have taken the Apress JSON data and created some slq scripts from it to populate the Authors, Books and BookAuthor tables. I didn't fill the Review or PriceOffer tables.
So now I have some data in my Db to start querying.

Regards, Nick.