locked
seeding an existing database RRS feed

  • Question

  • User65893105 posted

    Ive created a database using the database first method and generated the poco's from the ado.net entity data model and put them into a separate domain model project in my solution.  I wanted to seed the tables with some intial data but when I try I get tis error message

    Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations.

    I prefer to model the database using management studio so code first isnt an option.  Is there any way to do this ? Im using EF6

    Tuesday, February 14, 2017 10:54 AM

All replies

  • User2117486576 posted

    Seeding a database seems to be inconsistent with the database first theory.  When I was faced with the issue of wanting to maintain "seed" data in a database that was early in the dev process and therefore had rapid schema changes, I triggered a seed method from a controller action that I could hit in the dev environment.  It did not stay in the product long, however.

    If you prefer to model your database in SSMS, then write a script to seed the data and run it after schema changes.  

    Tuesday, February 14, 2017 1:02 PM
  • User1397563414 posted

    Hi misuk11,

    I guess it is because you change your database after to run your code, the poco entity and the database table are not matched.

    You can try to update the model by right-click anywhere on the design surface, and select Update Model from Database.


    Regards,
    JiyaoLee

    Wednesday, February 15, 2017 12:06 PM