本文介绍了实体框架7的DbContext支架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想生成一个的DbContext 使用ASP.NET 5和Entity Framework 7不足为奇现有的数据库结构,没有周围的很多文档如何做到这一点很容易。此外,我想只有脚手架的背景下;有〜900表,我只关心他们几个,我不需要模型类的每一个。

我一直在使用指定的命令here和here有一点运气。

所以,我想我有两个问题:


  1. 其中位于生成上下文文件?我跑在没有故障的命令提示符下命令,但没有什么事情发生。我知道我至少在正确的地方,我可以添加具有不受支持的属性,老EF6模型,它给了我,他们不支持的错误。


  2. 是否有可能产生只是一个没有相应的模型类方面?



解决方案

我和我的项目产生的背景和模特同样的问题。下面是我做了几件事情。

更新1.0 RC1低于

Project.json

 依赖:{
    EntityFramework.MicrosoftSqlServer:7.0.0-RC1决赛
    EntityFramework.Commands:7.0.0-RC1决赛
    EntityFramework.MicrosoftSqlServer.Design:7.0.0-RC1决赛
  },  命令:{
    EF:EntityFramework.Commands
  },  构架: {
    dnx451:{},
    dnxcore50:{}
  }

DNX命令

  DNX EF的DbContext脚手架的ConnectionStringEntityFramework.MicrosoftSqlServer

原文发表在

请确保这些被添加到您的project.json文件:

 依赖:{
    EntityFramework.SqlServer:7.0.0-联蛋白β7,
    EntityFramework.Commands:7.0.0-联蛋白β7,
    EntityFramework.SqlServer.Design:7.0.0-联蛋白β7
},
命令:{
    EF:EntityFramework.Commands
}

dnvm和DNX运行时以及使用的 dnvm更新自的和的 dnvm升级

升级。我在cmd中运行这个。

打开cmd.exe,在项目位置(如果你是在Windows中,导航到文件夹和Shift +文件夹中单击右键,然后单击打开命令窗口在这里)。在我来说,我有一个单独的项目对我的数据访问层
例如。

  C:\\项目\\实例#1 \\ SRC \\ StackoverflowExample.DAL \\

然后我通过Simplay跑:

Make sure your project can build. If there are errors, the commands probably wont work.

It generated all the models as well as the context (with the OnModelCreating() setup of each entity). If you don't need all the models, just delete the ones you are not using.

So to answer you questions:

  1. It creates the models and context in the folder where you ran the dnx ef dbcontext scaffold in.
  2. I cant see any commands that allows you to do this yet.Run dnx ef --help in cmd and look for yourself.dnx ef

I hope this helps.

这篇关于实体框架7的DbContext支架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 11:21
查看更多