Code First Migrations With Existing Table

2019-02-06 14:28发布

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; }
}

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."

1条回答
狗以群分
2楼-- · 2019-02-06 15:13

-IGNORECHANGES

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.

http://coding.abel.nu/2012/03/ef-migrations-command-reference/

查看更多
登录 后发表回答