-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix various issues for the first release
- Loading branch information
1 parent
d0c90ed
commit 545651c
Showing
19 changed files
with
341 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,40 @@ | ||
# TODO | ||
# C3D.MSBuild.Tools.EF6.GenerateViews | ||
|
||
An MSBuild based implementation of the [`Entity Framework 6 Power Tools Community Edition`](https://github.com/ErikEJ/EntityFramework6PowerTools) `Generate Views` command. | ||
|
||
The samples folder shows the use of the package with NETFramework and NETCore (.Net 5) | ||
|
||
This is for EntityFramework 6 only - not EFCore | ||
|
||
An example of how to get the EDMX file from your context file is given in the program main. | ||
It will write the EDMX for the context to the executable folder. | ||
You can copy this into your application directory. | ||
Ensure it is _not_ set to any build action or have any custom tool attached. | ||
|
||
Set the Build Action to EntityView | ||
|
||
Set the Custom Tool Namespace to match your database context's namespace. | ||
|
||
On build, the Views will be generated in the obj folder and automatically included in the build. | ||
|
||
If you are using Code-First migrations, you can add the following to automatically generate views based on the last edmx file in the migrations folder. | ||
|
||
```xml | ||
<ItemGroup> | ||
<EntityView Include="Migrations\**\*.edmx"> | ||
<CustomToolNamespace>GSHydro.CertificateManager.Models.DAL</CustomToolNamespace> | ||
</EntityView> | ||
</ItemGroup> | ||
``` | ||
|
||
## Known Properties | ||
|
||
`EntityFramework6GenerateViewsOutputDir` - Defaults to $(IntermediateOutputPath)\EntityViews | ||
|
||
## Known Items | ||
|
||
* `EntityView` - One or more edmx files used to generate the Views. Only the latest (alphabetically last) file is used. | ||
** `CustomToolNamespace` - Property of the `EntityView` item used to determine the namespace of the DBContext. The DBContext name itself is determined from the EDMX file. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<solution> | ||
<add key="disableSourceControlIntegration" value="true" /> | ||
</solution> | ||
<packageSourceCredentials> | ||
</packageSourceCredentials> | ||
<packageSources> | ||
<clear /> | ||
<add key="Local" value="$/../packages" /> | ||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> | ||
</packageSources> | ||
<activePackageSource> | ||
<!-- All non-disabled sources are active --> | ||
<add key="All" value="(Aggregate source)"/> | ||
</activePackageSource> | ||
<disabledPackageSources> | ||
</disabledPackageSources> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data.Entity; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NETCoreConsoleApp.Models | ||
{ | ||
public class SchoolContext : DbContext | ||
{ | ||
public SchoolContext() : base() | ||
{ | ||
|
||
} | ||
|
||
|
||
public DbSet<Student> Students { get; set; } | ||
public DbSet<Grade> Grades { get; set; } | ||
} | ||
|
||
public class Grade | ||
{ | ||
public int GradeId { get; set; } | ||
public string GradeName { get; set; } | ||
public string Section { get; set; } | ||
|
||
public ICollection<Student> Students { get; set; } | ||
} | ||
|
||
public class Student | ||
{ | ||
public int StudentID { get; set; } | ||
public string StudentName { get; set; } | ||
public DateTime? DateOfBirth { get; set; } | ||
public byte[] Photo { get; set; } | ||
public decimal Height { get; set; } | ||
public float Weight { get; set; } | ||
|
||
public Grade Grade { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="utf-8"?><Edmx Version="3.0" xmlns="http://schemas.microsoft.com/ado/2009/11/edmx"><Runtime><ConceptualModels><Schema Namespace="NETCoreConsoleApp.Models" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm"><EntityType Name="Grade" customannotation:ClrType="NETCoreConsoleApp.Models.Grade, NETCoreConsoleApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"><Key><PropertyRef Name="GradeId" /></Key><Property Name="GradeId" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" /><Property Name="GradeName" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" /><Property Name="Section" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" /><NavigationProperty Name="Students" Relationship="Self.Student_Grade" FromRole="Student_Grade_Target" ToRole="Student_Grade_Source" /></EntityType><EntityType Name="Student" customannotation:ClrType="NETCoreConsoleApp.Models.Student, NETCoreConsoleApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"><Key><PropertyRef Name="StudentID" /></Key><Property Name="StudentID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" /><Property Name="StudentName" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" /><Property Name="DateOfBirth" Type="DateTime" /><Property Name="Photo" Type="Binary" MaxLength="Max" FixedLength="false" /><Property Name="Height" Type="Decimal" Precision="18" Scale="2" Nullable="false" /><Property Name="Weight" Type="Single" Nullable="false" /><NavigationProperty Name="Grade" Relationship="Self.Student_Grade" FromRole="Student_Grade_Source" ToRole="Student_Grade_Target" /></EntityType><Association Name="Student_Grade"><End Role="Student_Grade_Source" Type="Self.Student" Multiplicity="*" /><End Role="Student_Grade_Target" Type="Self.Grade" Multiplicity="0..1" /></Association><EntityContainer Name="SchoolContext" customannotation:UseClrTypes="true"><EntitySet Name="Grades" EntityType="Self.Grade" /><EntitySet Name="Students" EntityType="Self.Student" /><AssociationSet Name="Student_Grade" Association="Self.Student_Grade"><End Role="Student_Grade_Source" EntitySet="Students" /><End Role="Student_Grade_Target" EntitySet="Grades" /></AssociationSet></EntityContainer></Schema></ConceptualModels><Mappings><Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs"><EntityContainerMapping StorageEntityContainer="CodeFirstDatabase" CdmEntityContainer="SchoolContext"><EntitySetMapping Name="Grades"><EntityTypeMapping TypeName="NETCoreConsoleApp.Models.Grade"><MappingFragment StoreEntitySet="Grade"><ScalarProperty Name="GradeId" ColumnName="GradeId" /><ScalarProperty Name="GradeName" ColumnName="GradeName" /><ScalarProperty Name="Section" ColumnName="Section" /></MappingFragment></EntityTypeMapping></EntitySetMapping><EntitySetMapping Name="Students"><EntityTypeMapping TypeName="NETCoreConsoleApp.Models.Student"><MappingFragment StoreEntitySet="Student"><ScalarProperty Name="StudentID" ColumnName="StudentID" /><ScalarProperty Name="StudentName" ColumnName="StudentName" /><ScalarProperty Name="DateOfBirth" ColumnName="DateOfBirth" /><ScalarProperty Name="Photo" ColumnName="Photo" /><ScalarProperty Name="Height" ColumnName="Height" /><ScalarProperty Name="Weight" ColumnName="Weight" /></MappingFragment></EntityTypeMapping></EntitySetMapping><AssociationSetMapping Name="Student_Grade" TypeName="NETCoreConsoleApp.Models.Student_Grade" StoreEntitySet="Student"><EndProperty Name="Student_Grade_Target"><ScalarProperty Name="GradeId" ColumnName="Grade_GradeId" /></EndProperty><EndProperty Name="Student_Grade_Source"><ScalarProperty Name="StudentID" ColumnName="StudentID" /></EndProperty><Condition IsNull="false" ColumnName="Grade_GradeId" /></AssociationSetMapping></EntityContainerMapping></Mapping></Mappings><StorageModels><Schema Namespace="CodeFirstDatabaseSchema" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl"><EntityType Name="Grade"><Key><PropertyRef Name="GradeId" /></Key><Property Name="GradeId" Type="int" StoreGeneratedPattern="Identity" Nullable="false" /><Property Name="GradeName" Type="nvarchar(max)" Nullable="true" /><Property Name="Section" Type="nvarchar(max)" Nullable="true" /></EntityType><EntityType Name="Student"><Key><PropertyRef Name="StudentID" /></Key><Property Name="StudentID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" /><Property Name="StudentName" Type="nvarchar(max)" Nullable="true" /><Property Name="DateOfBirth" Type="datetime" Nullable="true" /><Property Name="Photo" Type="varbinary(max)" Nullable="true" /><Property Name="Height" Type="decimal" Precision="18" Scale="2" Nullable="false" /><Property Name="Weight" Type="real" Nullable="false" /><Property Name="Grade_GradeId" Type="int" customannotation:Index="{ Name: IX_Grade_GradeId, Order: 0 }" Nullable="true" /></EntityType><Association Name="Student_Grade"><End Role="Grade" Type="Self.Grade" Multiplicity="0..1" /><End Role="Student" Type="Self.Student" Multiplicity="*" /><ReferentialConstraint><Principal Role="Grade"><PropertyRef Name="GradeId" /></Principal><Dependent Role="Student"><PropertyRef Name="Grade_GradeId" /></Dependent></ReferentialConstraint></Association><EntityContainer Name="CodeFirstDatabase"><EntitySet Name="Grade" EntityType="Self.Grade" Schema="dbo" Table="Grades" /><EntitySet Name="Student" EntityType="Self.Student" Schema="dbo" Table="Students" /><AssociationSet Name="Student_Grade" Association="Self.Student_Grade"><End Role="Grade" EntitySet="Grade" /><End Role="Student" EntitySet="Student" /></AssociationSet></EntityContainer></Schema></StorageModels></Runtime><Designer><Connection><DesignerInfoPropertySet><DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" /></DesignerInfoPropertySet></Connection><Options><DesignerInfoPropertySet><DesignerProperty Name="ValidateOnBuild" Value="False" /><DesignerProperty Name="CodeGenerationStrategy" Value="None" /><DesignerProperty Name="ProcessDependentTemplatesOnSave" Value="False" /><DesignerProperty Name="UseLegacyProvider" Value="False" /></DesignerInfoPropertySet></Options><Diagrams /></Designer></Edmx> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<EntityView Include="Models\NETCoreConsoleApp.edmx"> | ||
<CustomToolNamespace>NETCoreConsoleApp.Models</CustomToolNamespace> | ||
</EntityView> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="C3D.MSBuild.Tools.EF6.GenerateViews" Version="6.4.3-gd0c90ed8c3"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="EntityFramework" Version="6.4.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using NETCoreConsoleApp.Models; | ||
using System; | ||
|
||
namespace NETCoreConsoleApp | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
using (var ctx = new SchoolContext()) | ||
{ | ||
var stud = new Student() { StudentName = "Bill" }; | ||
|
||
ctx.Students.Add(stud); | ||
ctx.SaveChanges(); | ||
|
||
using (var edmxFile = System.IO.File.OpenWrite( | ||
System.IO.Path.ChangeExtension(ctx.GetType().Assembly.Location, ".edmx"))) | ||
{ | ||
using (var edmx = System.Xml.XmlWriter.Create(edmxFile)) { | ||
System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(ctx, edmx); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data.Entity; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NETFrameworkConsoleApp.Models | ||
{ | ||
public class SchoolContext : DbContext | ||
{ | ||
public SchoolContext() : base() | ||
{ | ||
|
||
} | ||
|
||
|
||
public DbSet<Student> Students { get; set; } | ||
public DbSet<Grade> Grades { get; set; } | ||
} | ||
|
||
public class Grade | ||
{ | ||
public int GradeId { get; set; } | ||
public string GradeName { get; set; } | ||
public string Section { get; set; } | ||
|
||
public ICollection<Student> Students { get; set; } | ||
} | ||
|
||
public class Student | ||
{ | ||
public int StudentID { get; set; } | ||
public string StudentName { get; set; } | ||
public DateTime? DateOfBirth { get; set; } | ||
public byte[] Photo { get; set; } | ||
public decimal Height { get; set; } | ||
public float Weight { get; set; } | ||
|
||
public Grade Grade { get; set; } | ||
} | ||
} |
Oops, something went wrong.