设为首页 加入收藏

TOP

Entity Framework工具POCO Code First Generator的使用(一)
2017-10-10 13:49:37 】 浏览:10038
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 https://www.pluralsight.com/courses/code-first-entity-framework-legacy-databases

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

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目