问题描述
我创建了两个Windows应用程序示例
i created two samples of windows application
首先是vs 2010和.net framework 4,以及在vs2012和.net Framework 4上也排名第二.
first on vs 2010 and .net framework 4 andsecond on vs2012 and .net framework 4 too.
我向其中添加了ado.net实体数据模型,但该模型因主题而异,首先需要具有以下文件:
i add ado.net entity data model to them but this model is deferente on theme first have this files:
1-mymodel.Designer.cs
秒:
1-mymodel.Context.tt
2-mymodel.Designer.cs
3-Mymodel.tt
4-mymodel.edms.diagram
为什么要尊重2022年的新增功能,对我来说重要的是,第一个具有默认构造函数,可让您创建自己的连接字符串,而第二个则没有任何构造函数,为什么?
why thee are deference is that new in vs 2022 and it is important for me that first has default constructor that let you create your own connection string but second hasn't any constructor,why?
推荐答案
EF 5按约定而不是按配置运行.
EF 5 operates by convention rather than by configuration.
创建自己的上下文,该上下文继承DbContext
并像这样传递连接字符串:
Create your own context that inherits DbContext
and pass in the connection string like so:
public class MyContext: DbContext
{
public MyContext()
: base([myConnectionString])
{
}
}
这篇关于为什么ado.net实体数据模型在vs 2012中进行了更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!