Invalid object name 'dbo.EdmMetadata' and 'dbo.__MigrationHistory'

后端 未结 3 858
萌比男神i
萌比男神i 2021-01-01 10:16

I am using Entity Framework 5 and doing a simple query to get a few users from a table.

The SQL database is already created so I use my entities as a way to map what

3条回答
  •  轮回少年
    2021-01-01 10:44

    Since the database is already there you will not have dbo.EdmMetadata and dbo.__MigrationHistory which codefirst is expecting. And to resolve this you can try to set the SetInitializer to null.

     static NameOfYourContext()
     {
       Database.SetInitializer(null);        
     }      
    

    You can see this in the comments section of the this post by Scott Gu

提交回复
热议问题