ASP.NET Core Web API .NET 6 2022 - 4. Installing Entity Framework

ASP.NET Core Web API .NET 6 2022 - 4. Installing Entity Framework

Teddy Smith

2 года назад

100,831 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Stoppy
Stoppy - 22.10.2023 18:13

Add-Migration succeeded for me, but with some warnings:
The foreign key property 'PokemonCategory.CategoryId1' was created in shadow state because a conflicting property with the simple name 'CategoryId' exists in the entity type, but is either not mapped, is already used for another relationship, or is incompatible with the associated primary key type.
Same goes with PokemonOwner.OwnerId1

Anyone with the same issue?

Ответить
NamesitoBaraya
NamesitoBaraya - 17.10.2023 08:42

Hello Teddy, In the DataContext example you have done, there seem to be a composite primary key used and when I was using a singular key i got lost can you provide some guidance

Ответить
JoshCloud
JoshCloud - 14.10.2023 17:47

Hello, i would like to join your discord channel, i get the message: invite has expired,

Ответить
NET tech
NET tech - 11.10.2023 19:05

This is the best explanation of EF core that I have ever seen. Thank you!

Ответить
Gerard Lanphear
Gerard Lanphear - 02.10.2023 17:40

I believe the popular plural of Pokemon is just "Mons".

Ответить
Kevin Andersch
Kevin Andersch - 30.09.2023 10:33

Man, i hate it when people say "just copy paste it" without at least explaining it a little bit. Lets stick to the most important error for this: the seed from the github repo is the FINISHED seed of the project (i assume), which is incompatable with the current status of the project (e.g. reviews suddenly have ratings, owners have first and last names etc). If some1 has trouble with it, either remove incompatabilities from the seed code or add those to the models.

Ответить
Maaz
Maaz - 25.09.2023 22:45

Hello teddy. I am getting the tables but there's no data inside. Every command got executed without any errors. Can you give me a clue as to what might have happened?

Ответить
Call_me_Cat
Call_me_Cat - 21.09.2023 22:29

I dont know if the course has been updated, but the seed columns doesn't match with de models. Informations such as Rating, FirstName, Last name in Owner and Review does not exist.

I checked the UML twice and still, seeds does not match.

Ответить
Sergio Sanc
Sergio Sanc - 20.09.2023 04:03

To seed data from the command line: `dotnet run seeddata`

Ответить
Han Chen
Han Chen - 19.09.2023 20:41

For anyone unable to add the SQL server in Visual Studio with an error that says cannot connect or find the SQL server, your connection name may not be the same as the Name in the property window. Instead, click on the "View Connection Properties" in the Server Properties window, and copy the server name instead. Put that in the "Server name" in the connect window in VS

Ответить
Sergio Sanc
Sergio Sanc - 18.09.2023 21:55

In this specific scenario, what would be the best way to add additional restrictions to fields? for instance, Max Limit of character of the Country, or the Review integer can only be from 1 to 5?

Ответить
Quân Hồng
Quân Hồng - 07.09.2023 06:37

sorry i coppy code file Seed.cs but it error with "review"

Ответить
Oana Ghicajanu
Oana Ghicajanu - 06.09.2023 12:55

hah you're so funny 🤣🤣🤣🤣

Ответить
安格斯 Angus
安格斯 Angus - 24.08.2023 17:59

Really really useful! Thanks !

Ответить
Lukas Čaplikas
Lukas Čaplikas - 24.08.2023 13:53

Maybe you will know the problem. I use AzureSQL and when I try to execute migrate I receive error:
The SELECT permission was denied on the object '__EFMigrationsHistory', database 'master', schema 'dbo'.
Currently still figuring out how to grant access to master. But still no hope.

Ответить
Joey Estrada
Joey Estrada - 20.08.2023 23:04

Man, I'm getting an error on this last step. Does anyone know how to fix it?

Ответить
büşra uçar
büşra uçar - 18.08.2023 10:30

Hi, Although I create the seed data in the same way, the database is created, all tables are coming, but the data in the tables are not. What could be the problem here?

Ответить
Ralph Weber
Ralph Weber - 11.08.2023 03:56

Lets rock with a database

Ответить
Trash Bin
Trash Bin - 10.08.2023 11:34

Teddy, thank you man! You have no idea how helpful I'm finding your content to be!

Ответить
Orlando YV
Orlando YV - 07.08.2023 06:32

Question, is there a way to avoid all this DB creation by sharing a database? it is not easier to share a file of a database?

Ответить
The Roosting roaster
The Roosting roaster - 02.08.2023 10:58

When I copied the seed file from your github I was getting red squiglies under rating for reviews and FirstName and LastName, I don't remember you adding them to the models. Or does this have something to do with the relationships. Maybe I messed up there. IF someone had a similar issue would appreciate any help.

Ответить
Ngoc Anh
Ngoc Anh - 01.08.2023 11:11

Did you change the Model??? The seed was error

Ответить
Арнольд Айзкалнс
Арнольд Айзкалнс - 26.07.2023 10:48

Add migrations errors, update errors, seed errors... nice course :(

Ответить
Opomomlslsa
Opomomlslsa - 19.07.2023 04:28

why we need that seed class plz someone explain how it works? do I need to do the same for my own projects?

Ответить
afaq ahmed
afaq ahmed - 18.07.2023 09:51

Thank you for such a cool tutorial. Keep it up🤓👍

Ответить
Nguyen Monat Son
Nguyen Monat Son - 04.07.2023 01:56

Thank you sir. This is gold!

Ответить
Wit ΧαοΣ
Wit ΧαοΣ - 27.06.2023 22:14

this is the best tutorial I've found so far. As another said this is enterprise level and cover a lot of topics. Nice

Ответить
Almonia, Ruel A.
Almonia, Ruel A. - 17.06.2023 06:39

Hello, what is the alternative way if I dont use the Add-Migration? In our task, they say that we need to avoid code first approach with migration.

Ответить
Neel
Neel - 16.06.2023 17:24

Is seed class same as migration..

Ответить
Console.WriteLine
Console.WriteLine - 16.06.2023 11:06

I've spent weeks trying to watch how to connect to database... and everywhere i was getting some kind of error. but with you it was so easy!

Ответить
Da Bunnisher
Da Bunnisher - 07.06.2023 07:16

Sorry, but this is a shit show for new beginners.

Ответить
Brian James Gresos
Brian James Gresos - 02.06.2023 12:44

Are you using SQL Express Core?

Ответить
Austin Branham
Austin Branham - 26.05.2023 03:50

Anyone else get this error 'Owner' cannot be used as a property on entity type 'PokemonOwner' because it is configured as a navigation.

Ответить
Aisyah
Aisyah - 25.05.2023 12:50

Hello Teddy, I really appreciate your effort making these tutorial videos. Your steps really clear and easy to understand. Thank you very much!

Ответить
Addy Beez
Addy Beez - 20.05.2023 10:09

When you create Rating filed ,it's gave me error

Ответить
BuhZeeBu
BuhZeeBu - 13.05.2023 15:30

OMG Your tips to the databases (connection string) was so amazing. Love you good works, thank you!

Ответить
Darren Parker
Darren Parker - 04.05.2023 17:06

Lol.......I remember watching this a year ago and thinking "WTF, how am I ever gonna learn this?". Now, I've just popped back to recap on fluent api many to manys. You're a star, Teddy and to anyone else thinking "How the f**k am I gonna learn this?", you WILL understand it. Just keep practicing under the guidance of Don Ted ;)

Ответить
Crypto Boomer
Crypto Boomer - 28.04.2023 23:37

Any advice to connect visual studio to sql server running in docker. The sql server object explorer doesn't work and google replies suck

Ответить
WENG YIN
WENG YIN - 27.04.2023 03:51

👍👍

Ответить
Denis Dutu
Denis Dutu - 06.04.2023 21:00

If you use an local server like he does you can only type "." (a dot without the strings) insteat of copying the whole name

Ответить
Sahith Shetty
Sahith Shetty - 02.04.2023 01:15

Didn't anyone get errors in the seed file. In the seed file provided in teddy's github link, there are firstname and lastname in the owner. But while creating the owner modal, we didnt include them. Did anyone did something about this?

Ответить
DjHenrik
DjHenrik - 26.03.2023 23:02

ur funny dude

Ответить
Sajad CH
Sajad CH - 23.03.2023 12:25

if there is database already..do we need to use migration...pls rply sir

Ответить
Jan
Jan - 21.03.2023 17:58

Hi Teedy i get this exeption when seeding the data:

An exception occurred in the database while saving changes for context type 'BasketballPlayerReviewApp.Data.DataContext'.
System.InvalidOperationException: The value of 'BrandDeal.BrandId' is unknown when attempting to save changes. This is because the property is also part of a foreign key for which the principal entity in the relationship is not known.

It has a problem with many to many relationship. Im doing a diffrent review app but the implemantation is kinda the same as yours. Pls help.

Ответить
K her
K her - 20.03.2023 21:34

You can use also
using (var seeder = scopedFactory.CreateScope())
{
var service = seeder.ServiceProvider.GetService<Seed>();
service.SeedDataContext();
}
and register Seed as scoped
builder.Services.AddScoped<Seed>();

No need to use CLI to seed then ;)

Ответить
Mitul Gupta
Mitul Gupta - 17.03.2023 14:36

If facing an error during Add-Migration InitialCreate with build failed then do some changes owner(first name and last name instead of just name ) and review (add ratings)class

Ответить
S Uv
S Uv - 14.03.2023 18:14

Guys if you have a problem with your Add-Migration and nothing helps, make sure you delete the stuff in your Controllers folder in solution explorer. I forgot to delete the WeatherForecast default app controller and it messed up my build

Ответить