Are there Database Initializers in Entity Framework Core?

对着背影说爱祢 提交于 2020-02-02 00:30:32

问题


I can't find examples on how to use EF Database Initializers with EF Core nor can I find a list of EF Database Initializers shipping with EF Core.

Has the concept of Database Initializers become obsolete? What's the current approach of initializing a database ... or not initializing an existing database?


回答1:


In .Net core you can use functions of Database property form DbContext instance. It allows you to create database (EnsureCreated), destroy database (EnsureDeleted) and migrate to last migration (Migrate). Required data should be placed in migrations. Look at last section of https://docs.microsoft.com/ef/core/managing-schemas/migrations/ for more details.



来源:https://stackoverflow.com/questions/47066175/are-there-database-initializers-in-entity-framework-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!