$ C C首先迁徙,现有表$ [英] Code First Migrations With Existing Table

查看:174
本文介绍了$ C C首先迁徙,现有表$的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的模型我有导航属性语言:

In my model I have navigation property Language:

public class IntegratorDescription : BaseContract
{
    [Key, Column(TypeName = "bigint"), DataMember]
    public long Id { get; set; }
    [DataMember, Column(TypeName = "bigint"), ForeignKey("Language")]
    public long LangId { get; set; }
    [DataMember]
    public string CompanyShortInfo { get; set; }
    [DataMember, Column(TypeName = "ntext")]
    public string CompanyInfo { get; set; }

    public virtual Models.Language Language { get; set; }
}

语言表已经存在,它的另一个ORM做的,我需要说迁移没有尝试创建语言表,但只更新说明表。怎么样?

Language table already exists and it's done by another ORM, I need to say Migrations not to try to create Language table but update only Description table. How?

- 已存在数据库中的命名为语言的对象

-"There is already an object named 'Languages' in the database."

推荐答案

-IGNORECHANGES

-IGNORECHANGES

支架一个空迁移忽略当前模型检测到的挂起更改。这可以用于创建初始的空迁移启用迁移为现有的数据库。 N.B.这样做假定目标数据库架构与当前型号兼容。

Scaffolds an empty migration ignoring any pending changes detected in the current model. This can be used to create an initial, empty migration to enable Migrations for an existing database. N.B. Doing this assumes that the target database schema is compatible with the current model.

<一个href="http://coding.abel.nu/2012/03/ef-migrations-command-reference/">http://coding.abel.nu/2012/03/ef-migrations-command-reference/

这篇关于$ C C首先迁徙,现有表$的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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