Skip to content

Document deployment and seeding patterns #736

@Silthus

Description

@Silthus

Updated to reflect the core issue we are tracking here:

TL;DR: It is very hard to come up with really good guidance on how create or update application state on deployment. Note that this is commonly related to database schema and seed data, but it is not limited to that.

Many customers end up adding logic at application startup because that runs after deployment, but this is very problematic, especially if there is more than one instance of the application using the same database.

We think this ideally should happen as a post-deployment step, not startup.

We would like to do some brainstorming with a wider group with the goal of identifying patterns that we can recommend today and/or functionality that we can build into the publish components to make this work.

Original issue as reported:

How can the key of an entity be specified? I have an entity that should be seeded based on its name and the ID (Guid) is generated automatically. Something like this:

modelBuilder.Entity<Blog>().HasData(blog => blog.Name, new Blog {Name = "New Blog", Url = "http://sample.com"});

And for composite keys:

modelBuilder.Entity<Blog>().HasData(blog => new {blog.Name, blog.Url}, new Blog {Name = "New Blog", Url = "http://sample.com"});

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions