标签:enable C# DB 如下 编译 INIT DefineConstants ConfigureExternalServices define
在VS2017或者更高的版本中
可以在程序集的属性来修改,如下:
也可以按照如下方式修改代码:
1 <Project Sdk="Microsoft.NET.Sdk"> 2 3 <PropertyGroup> 4 <TargetFramework>net6.0</TargetFramework> 5 <ImplicitUsings>enable</ImplicitUsings> 6 <Nullable>enable</Nullable> 7 </PropertyGroup> 8 9 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> 10 <DefineConstants>$(DefineConstants);INIT_DB</DefineConstants> 11 </PropertyGroup> 12 13 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> 14 <DefineConstants>$(DefineConstants);INIT_DB</DefineConstants> 15 </PropertyGroup> 16 17 <ItemGroup> 18 <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> 19 <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" /> 20 <PackageReference Include="SqlSugarCore" Version="5.1.2.2" /> 21 </ItemGroup> 22 23 <ItemGroup> 24 <ProjectReference Include="..\Common.Domain\Common.Domain.csproj" /> 25 </ItemGroup> 26 27 </Project>
文件中的使用方案:
#if INIT_DB //only when your want to init db ConfigureExternalServices = new ConfigureExternalServices { EntityService = (c, p) => { if (p.PropertyName.Equals(nameof(Common.Domain.LogicDeleted.IsDeleted))) { p.IsPrimarykey = true; } } }, #endif
标签:enable,C#,DB,如下,编译,INIT,DefineConstants,ConfigureExternalServices,define 来源: https://www.cnblogs.com/skying9/p/16644424.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。