Creating initializers

The database initializers provided by the .NET Framework have the basics covered, but there are often good reasons to create your own. You might want the decision to create a new database to be more sophisticated, or based on user input. You might want to check alternate loctaions before making the decision. Or you might want to leverage the Seed() method provided by the existing concrete classes to add some core data to the dictionary when it’s created. Here’s how:


Add the initializer class to your project

You’ll typically add the class to the data access layer. If you’re not going to be seeding data, you can implement ...

Get Fluent Entity Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.