简体   繁体   English

EF 4.1-从不同计算机上的同一应用访问数据库时出现问题

[英]EF 4.1 - Problem accessing DB from same app on different machines

I have deployed an application that uses EF to the same server as my DB. 我已经将使用EF的应用程序部署到了与数据库相同的服务器上。 Obviously the first time I ran the app on the server the DB was created - no problems. 显然,我是第一次在数据库服务器上运行该应用程序-没问题。

However, when I attempt to run the same application from my local machine using the same connection string / login details as the instance running on the server, I get this exception saying the model has changed, although it hasn't: 但是,当我尝试使用与服务器上运行的实例相同的连接字符串/登录详细信息从本地计算机运行相同的应用程序时,出现此异常,说明模型已更改,尽管它没有更改:

The model backing the 'EkmDomainsDbContext' context has changed since the database was created. 自创建数据库以来,支持“ EkmDomainsDbContext”上下文的模型已更改。 Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. 手动删除/更新数据库,或使用IDatabaseInitializer实例调用Database.SetInitializer。 For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data. 例如,DropCreateDatabaseIfModelChanges策略将自动删除并重新创建数据库,并可以选择用新数据作为种子。

I assume this is something to do with the EdmMetadata table, but I am not sure exactly what. 我认为这与EdmMetadata表有关,但是我不确定到底是什么。 Can anyone shed any light on this problem? 任何人都可以阐明这个问题吗?

现有数据库通常不需要任何数据库初始化程序,因此可以通过调用以下上下文类型将其关闭:

Database.SetInitializer<YourDataContext>(null);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM