如何调用Database.SetInitializer型号为先? [英] How to call Database.SetInitializer on model-first?

查看:156
本文介绍了如何调用Database.SetInitializer型号为先?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用的DbContext实体生成器为代项目在EDM设计模型(VS10)。

I created a model in the edm designer (VS10) using "DbContext Entity Generator" as the generation item.

在生成的DbContext的子类,它覆盖了构造函数,所以我不能在其他部分的类使用它:

In the generated DbContext subclass, it overrode the constructor so I can't use it in the other partial class:

public EntitiesContainer()
    : base("name=EntitiesContainer")
{
    this.Configuration.LazyLoadingEnabled = false;
}

什么是初始化模式,第一数据库的正确方法是什么?

What's the proper way of initialize a database with model-first?

推荐答案

您可以改变这种正在被用于生成DbContxt类的T4模板。然后,你可以添加你要用来初始化上下文部分改性剂或方法。

You could alter the T4 template that's being used for generating the DbContxt class. Then you could add the partial modifiers or methods that you want to use to initialize your context.

这篇关于如何调用Database.SetInitializer型号为先?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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