EF 4.1代码第一和现有数据库和.NET成员资格 [英] EF 4.1 Code First and Existing Database and .NET Membership

查看:90
本文介绍了EF 4.1代码第一和现有数据库和.NET成员资格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的开发框中有一个名为ApplicationName_Development的数据库,运行在SQL Server 2008 R2 Developer Edition上。



我将.NET成员资格表添加到数据库中没有任何问题。当我尝试获取代码优先工作时,我收到以下错误消息:


服务器遇到错误
处理请求。
消息的异常是模型兼容性不能
被检查,因为数据库
不包含模型元数据。确保
IncludeMetadataConvention已将
添加到DbModelBuilder
约定


经过一些搜索,我发现我不得不删除数据库,让EF创建数据库,没关系我丢失了所有的.NET会员资格表,我可以再次添加会员表,但如果我的模型发生变化,而EF需要重新创建数据库,那么我必须再次添加会员表。



如何解决这个问题?

解决方案

在这里找到一个更容易的解决方法,希望这有助于。



http://www.paragm.com/ef-v4-1-code-first-and-asp-net-membership-service/


I have a database called ApplicationName_Development running on SQL Server 2008 R2 Developer edition on my development box.

I added .NET membership tables to the database with no problem. When I tried to get Code First working I received the following error message:

The server encountered an error processing the request. The exception message is "Model compatibility cannot be checked because the database does not contain model metadata. Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions.

After some googling, I discovered that I had to delete the database and let EF create the database. That's fine but I lost all my .NET membership tables. I can go back in and add the membership tables again but if my model changes and EF needs to recreate the database then I have to add the membership tables in again.

How do I get around this?

解决方案

Found a easier workaround here. I hope this helps.

http://www.paragm.com/ef-v4-1-code-first-and-asp-net-membership-service/

这篇关于EF 4.1代码第一和现有数据库和.NET成员资格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆