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

every time use Add migration, ef wants to update all seeded data #30116

Closed
SEmadH opened this issue Jan 23, 2023 · 2 comments
Closed

every time use Add migration, ef wants to update all seeded data #30116

SEmadH opened this issue Jan 23, 2023 · 2 comments

Comments

@SEmadH
Copy link

SEmadH commented Jan 23, 2023

Hi,
I`m using separate files for seeding data

for example i have file as BaseTablesSeedData.cs

 public class BaseTablesSeedData
    {
        public static void SeedData(ModelBuilder modelBuilder)
        {
var Cities = new List<City>() {
                new City { Id = 1, Code = "Abadan".ToPascalCase(), CountryId = 101, Name_EN = "Abadan".ToPascalCase(), Name_Local = "آبادان", TimeZone = "01" },
                new City { Id = 2, Code = "Abha".ToPascalCase(), CountryId = 184, Name_EN = "Abha".ToPascalCase(), Name_Local = "", TimeZone = "01" },
                new City { Id = 3, Code = "Abidjan".ToPascalCase(), CountryId = 42, Name_EN = "Abidjan".ToPascalCase(), Name_Local = "", TimeZone = "01" },
                new City { Id = 4, Code = "AbuDhabi".ToPascalCase(), CountryId = 2, Name_EN = "AbuDhabi".ToPascalCase(), Name_Local = "ابوظبي", TimeZone = "01" }


  modelBuilder.Entity<City>().HasData(Cities.ToArray());
}
}

onModelCreating :

 protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //Base Tables Config
            BaseTablesSeedData.SeedData(modelBuilder);
}

every time I generate new migration all data wants to be update.

Screenshot 2023-01-23 134952

@ajcvickers
Copy link
Contributor

This issue is lacking enough information for us to be able to fully understand what is happening. Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate.

@SEmadH SEmadH closed this as completed Jan 25, 2023
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2023
@ajcvickers
Copy link
Contributor

Possible duplicate of #29985.

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

2 participants