实体框架5代码优先。如何指定我想删除的表? [英] Entity Framework 5 Code First. How to specify the tables that I would like to drop?

查看:101
本文介绍了实体框架5代码优先。如何指定我想删除的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除一些表并按照我的模型设计再次创建。但CodeFirst永远不会这样做,继续尝试应用我所做的更改,但由于某种原因他不能。模型类的设计是可以的,但SQL上的表不是,这就是为什么,并希望再次删除和重新创建。 我需要保留所有其他表的数据。



我对模型进行了一些更改,尤其是键和外键。那么为什么我认为如果我可以设置哪些表格我想放弃,代码首先会理解我的新实现。



Erro输出更新数据库




无法确定类型'Target.Data.Model.TacticalGoal'和'Target.Data.Model.ICB'之间关联的主要结束。必须使用关系流畅API或数据注释显式配置此关联的主要结尾。

I want to drop some tables and create again following my models design. But the CodeFirst never do it, keeping trying to apply the changes that I did, but for some reason he can't. The Designs of models class is ok but the tables on SQL is not and thats why and want to drop and recreate again. I need to keep the data of all others tables.

I did some changes on model and especially with keys and Foreign Keys. So why I think if I could set which tables I would like to drop, code first will Understand my new implementation.

Erro output update-database


Unable to determine the principal end of an association between the types 'Target.Data.Model.TacticalGoal' and 'Target.Data.Model.ICB'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.

推荐答案

刚开始:



Entity-Framework-Sample-Application-for-初学者


谷歌的实体框架5代码优先迁移,你会发现你正在寻找的东西。
Google for "entity framework 5 code first migrations" and you'll find what you're looking for.


这篇关于实体框架5代码优先。如何指定我想删除的表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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