I have an EF 5 Code First VS 2012 project and some entites. I use update-database to generate/seed the tables and data. However I have 4 existing tables with data, and I would like to map this tables to 4 POCO class, because I would like to access them via DbContext.
My problem if I create the entity POCO classes, and add the approprite
public DbSet<MyExternal> MyExternals { get; set; }
property to my DbContext class, when I run the update-database it tries to create the tables and exits with error "Table MyExternal is exists" or similar. I understand why is that, but my question: How to explain to the update-database process to not create/alter these tables?
Note: I know how to map tables to different names than class name etc, not this is my problem.
I know this question is rather old and probably answered by yourself, but the solution might be to create an empty migration:
public override void Up()
{
}
public override void Down()
{
}
Afterwards your Migration has stored the correct database model (in which your four tables are known) and everything should work out just fine
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.