Entity Framework工具POCO Code First Generator的使用(一)
2017-10-10 13:49:37 】 浏览:10586次 本网站的内容取自网络,仅供学习参考之用,绝无侵犯任何人知识产权之意。如有侵犯请您及时与本人取得联系,万分感谢。
Tags:Entity Framework 工具 POCO Code First Generator 使用

在使用Entity Framework过程中,有时需要借助工具生成Code First的代码,而Entity Framework Reverse POCO Code First Generator是一款不错的工具

在Visual Studio中,通过“工具”→“扩展和更新...”来安装Entity Framework Reverse POCO Code First Generator


这里添加一个控制台项目,并在项目中添加POCO Code First Generator 生成模板(注意:添加项目后需要添加Entity Framework,POCO Code First Generator借助Entity Framework生成代码,可以使用Nuget添加)




<#@ include file="EF.Reverse.POCO.Core.ttinclude" #>
<# // v2.32.0 // Please make changes to the settings below. // All you have to do is save this file, and the output file(s) is/are generated. Compiling does not regenerate the file(s). // A course for this generator is available on Pluralsight at

    // Main settings **********************************************************************************************************************
    ConnectionStringName = "MyDbContext";   // Searches for this connection string in config files listed below in the ConfigFilenameSearchOrder setting // ConnectionStringName is the only required setting. // As an alternative to ConnectionStringName above, which must match your app/web.config connection string name, you can override them below //ConnectionString = "Data Source=(local);Initial Catalog=Northwind;Integrated Security=True;Application Name=EntityFramework Reverse POCO Generator"; //ProviderName = "System.Data.SqlClient"; // Namespace = ""; // Override the default namespace here
    DbContextName = "MyDbContext"; // Note: If generating separate files, please give the db context a different name from this tt filename. //DbContextInterfaceName = "IMyDbContext"; // Defaults to "I" + DbContextName or set string empty to not implement any interface.
    DbContextInterfaceBaseClasses = "System.IDisposable";    // Specify what the base classes are for your database context interface
    DbContextBaseClass = "System.Data.Entity.DbContext";   // Specify what the base class is for your DbContext. For ASP.NET Identity use "IdentityDbContext<ApplicationUser>" //DefaultConstructorArgument = "EnvironmentConnectionStrings.MyDbContext"; //defaults to "Name=" + ConnectionStringName
    ConfigurationClassName = "Configuration"; // Configuration, Mapping, Map, etc. This is appended to the Poco class name to configure the mappings.
    ConfigFilenameSearchOrder = new[] { "app.config", "web.config" }; // Add more here if required. The config files are searched for in the local project first, then the whole solution second.
    GenerateSeparateFiles = false; MakeClassesInternal = false; MakeClassesPartial = false; MakeDbContextInterfacePartial = false; UseMappingTables = true; // If true, mapping will be used and no mapping tables will be generated. If false, all tables will be generated.
    UsePascalCase = true;    // This will rename the generated C# tables & properties to use PascalCase. If false table & property names will be left alone.
    UseDataAnnotations = false; // If true, will add data annotations to the poco classes.
    UseDataAnnotationsSchema = false; // UseDataAnnotations must also be true. If true, will add data annotations schema to the poco classes.


Entity Framework工具POCO Code First Generator的使用(一)

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 1/9/9
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇 MVC 上传文件 System.Web.. 下一篇Wpf TemplateBinding


验 证 码:
表  情:
内  容: