Entity framework core seed data

Поділитися
Вставка
  • Опубліковано 7 січ 2025

КОМЕНТАРІ • 51

  • @lipsakitchen
    @lipsakitchen 5 років тому +7

    Thanks alot.u r my guru.i learn everything from Ur tutorial. ,God bless u.

  • @naodagere8210
    @naodagere8210 4 роки тому +2

    Always you inject us with best practices. Thank you.

  • @MenziManqele
    @MenziManqele 2 роки тому

    Simple & clean. Thanks 🤜🤛

  • @AlThePal78
    @AlThePal78 3 роки тому

    I was trying to figure out how to show the data in visual studio like you did 28 secs into it because I forgot. Thank you :)

  • @Sysshad
    @Sysshad 5 років тому

    Smart solution, this way the content is only added once in the database, which could be a problem with other seed solutions.

  • @talkathiriify
    @talkathiriify 5 років тому

    Great job
    Thank you very much

  • @aurielmatthew7038
    @aurielmatthew7038 2 роки тому +1

    my new employee changes are showing on the EmployeeDB table but not on my web server(Microsoft edge), anyone know why?

  • @myentertenment8016
    @myentertenment8016 5 років тому +5

    How can seed data for multiple tables with the reference key?

  • @adminos15
    @adminos15 4 роки тому

    Thank u very much sir!
    Obviously i was forgetting to add it as a migration.

  • @shankarsammy23
    @shankarsammy23 4 роки тому

    Thanks so much dear sir!!

  • @morsheddld
    @morsheddld 4 роки тому +1

    u didn't show how u got 2:11 "Dept.IT" . it seems to be ENUM,isn't it?

  • @Suecia2020
    @Suecia2020 5 років тому

    Excellent !!!!

  • @jaymeoliveira
    @jaymeoliveira 3 роки тому

    Thanks alot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @rahulsbhatt
    @rahulsbhatt 3 роки тому

    Is it necessary to seed data before anything done with http requests because I ran into a problem where the database got updated with only null values everytime I hit a http post request.

  • @bashirmanafikhi
    @bashirmanafikhi 5 років тому

    شكرا كتير ♥

  • @gangadharkaranapu9062
    @gangadharkaranapu9062 4 роки тому

    Suppose we are modernizing an app. do we need to seed the entire data? or Is this just works for new Apps only?

  • @OldManRik
    @OldManRik 3 роки тому +1

    What's the point though I don't get it. It's not even a good strategy for testing.

  • @kmachinev
    @kmachinev 2 роки тому

    Hello. thanks for your videos. One question please, If the amount of data is large, is there any other efficient way to do data seeding?

  • @pandey3128
    @pandey3128 5 років тому

    Thanks a lot for this video. But there is a problem i am facing. After creating Extension Method "Seed" and moving auto-generated code in this Seed method, when i try to again run Scaffold command then old manual changes are erased.

  • @n2wbas
    @n2wbas 2 роки тому

    Great job
    but how can i make this code just run on create table or if table empty
    i have a problem every i add-migration add rows to database

  • @willemvanderwalt9506
    @willemvanderwalt9506 4 роки тому

    Quick question. Affter adding the seed migrations, my migrations folder in the Solution Explorer now looks quite messy. What is the correct procedure for removing the "SeedEmployeesTable" and "AlterSeedEmployeesTable" migrations from the Solution Manager?
    Thank you for your videos. They really do help a lot

    • @conaxliu9677
      @conaxliu9677 4 роки тому +1

      If the migration has already been applied using Update-Database, then the database needs to be reverted first. In this case, run
      Update-Database -migration InitialMigration
      This rolls back the database to when InitialMigration was applied.
      Then you can use Remove-Migration to remove the migrations created after the InitialMigration.

  • @gangwargajendra
    @gangwargajendra 5 років тому

    Hi venkat .I m waiting react js with mvc core ..

  • @SatinderSingh_t
    @SatinderSingh_t 5 років тому

    Hi venkat,
    am eagerly waiting for videos regarding Razor in Asp.net core

  • @buskilamaor9587
    @buskilamaor9587 5 років тому

    great video...i'm a bit confused, wasn't the seeding process was just a static example? otherwise what is the right process for generic user typed data being saved to the db?

    • @qw7997
      @qw7997 5 років тому

      When controller received user typed data, the action in controller will call the method in repository, and then repository will call dbcontext to interact with database and save user typed data

  • @mrmoinn
    @mrmoinn 5 років тому +1

    When I try to update the database for the SeedEmployeesTable migration, I get an error:
    Violation of PRIMARY KEY constraint 'PK_Employees'. Cannot insert duplicate key in object 'dbo.Employees'. The duplicate key value is (1).
    The statement has been terminated.
    Someone please help!
    Edit: I screwed around trying to fix everything but for some reason the migrations weren't being updated to the database properly and I deleted everything from the database and tried to add mary and john by running the website but then they show up as having id's of 4 and 5 instead of starting at 1 and I'm really confused and panicking and I can't edit the ids from the view data window in visual studioooooo

    • @willemvanderwalt9506
      @willemvanderwalt9506 4 роки тому

      It is possible that you PrimaryKey attribute is set to auto increment. A primarykey cant have duplicates in a column. So every time you delete a row, the SQL server remembers this action and iterates the id key

  • @roryatwork1635
    @roryatwork1635 5 років тому

    Nice video. Is there any way to use auto increment on the ID rather than entering the value.

    • @rcprietogmail
      @rcprietogmail 5 років тому

      Yes, use this data annotation
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int Id { get; set; }

  • @sanjayparate645
    @sanjayparate645 5 років тому +1

    Can you create tutorials how can I use multiple dbcontext for more than 1 database

  • @eugene-white-shark
    @eugene-white-shark 3 роки тому

    thank you

  • @ezeemmanuel3796
    @ezeemmanuel3796 4 роки тому

    Thanks alot

  • @Okolieazubuike
    @Okolieazubuike 5 років тому +1

    .HasData method has red underline. Please help

  • @christobanistan8887
    @christobanistan8887 5 років тому

    I guess no one at Microsoft ever had to massage data during an actual migration. Say you decide to split the data in a "Name" column into a "FirstName" and "LastName" column by looking for the last space.

  • @jk02
    @jk02 3 роки тому

    I have this error (The seed entity for entity type 'User' cannot be added because a non-zero value is required for property 'uid'. Consider providing a negative value to avoid collisions with non-seed data). Please help.

  • @gauravchauhan2259
    @gauravchauhan2259 5 років тому +1

    Could you add a video about AutoMapper?

  • @ljupconewman9357
    @ljupconewman9357 5 років тому

    Is there a reason why we would ever seed the database this way instead of in the UI?

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  5 років тому +3

      One use-case I can think of is, if you want to populate tables that contain data of dropdownlist controls. For example, you might have a dropdownlist that displays list of countries, states, departments in a company etc. If you want to make sure to have all these tables populated, one approach is to use this seeding technique. You can include the code to create the table and populate it with required initial list data in a single migration if you want to. Hope this answers your question.

    • @ljupconewman9357
      @ljupconewman9357 5 років тому

      @@Csharp-video-tutorialsBlogspot Oh so something that will never or rarely change, like enums in c#. Thanks!

  • @D4rkNi9ht
    @D4rkNi9ht 4 роки тому

    Thanks

  • @shakhawathrayhan5018
    @shakhawathrayhan5018 5 років тому +2

    1st view

  • @honeytrippers
    @honeytrippers 5 років тому +1

    the prev and next video links at the end of this video are wrong

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  5 років тому +1

      Hello Honeytrippers - Thank you very much for letting me know. I have now updated with the correct previous and next videos. Cheers!

  • @hansinilakshmi9686
    @hansinilakshmi9686 3 роки тому

    Entity framework is very confusing, which one is best "EF" or "ADO"
    Pls reply

  • @mattomwit
    @mattomwit 4 роки тому +1

    I found information that this way of adding seed data is nor recommended for adding user data. It works and could be used for essential data that your app will never work without. Here is a thread explaining how to implement seed data. stackoverflow.com/questions/50785009/how-to-seed-an-admin-user-in-ef-core-2-1-0
    If anyone disagrees please leave me a comment below explaining why that is. I am leaning myself right now and I need all the information I can find on the topic.

  • @miroslavpetrov3006
    @miroslavpetrov3006 4 роки тому

    How to seed a database with relations?

  • @himanshuk6199
    @himanshuk6199 4 роки тому

    You haven't showed how to seed related data..