Skip to content

Commit

Permalink
Merge pull request #115 from linq2db/master
Browse files Browse the repository at this point in the history
Release 5.1.5
  • Loading branch information
sdanyliv authored Feb 18, 2021
2 parents 4ca3158 + a4d1b31 commit 925055c
Show file tree
Hide file tree
Showing 20 changed files with 676 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Build/linq2db.Default.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>5.1.4</Version>
<Version>5.1.5</Version>

<Authors>Svyatoslav Danyliv, Igor Tkachev, Dmitry Lukashenko, Ilya Chudin</Authors>
<Product>Linq to DB</Product>
Expand Down
5 changes: 5 additions & 0 deletions Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = tru
var isIdentity = prop.GetAnnotations()
.Any(a => a.Name.EndsWith(":ValueGenerationStrategy") && a.Value?.ToString() == "IdentityColumn");

if (!isIdentity && isPrimaryKey)
{
isIdentity = prop.ValueGenerated == ValueGenerated.OnAdd;
}

var storeObjectId = GetStoreObjectIdentifier(et);

return new T[]{(T)(Attribute) new ColumnAttribute
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\Build\linq2db.Tests.props" />

<ItemGroup>
<Compile Remove="Models\UniversalEntities\**" />
<EmbeddedResource Remove="Models\UniversalEntities\**" />
<None Remove="Models\UniversalEntities\**" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Source\LinqToDB.EntityFrameworkCore\linq2db.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\LinqToDB.EntityFrameworkCore.BaseTests\LinqToDB.EntityFrameworkCore.BaseTests.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using LinqToDB.EntityFrameworkCore.BaseTests.Models.Northwind;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace LinqToDB.EntityFrameworkCore.SQLite.Tests.Models.Northwind.Mapping
{
public class CategoriesMap : IEntityTypeConfiguration<Category>
{
public void Configure(EntityTypeBuilder<Category> builder)
{

builder.HasKey(e => e.CategoryId);

builder.HasIndex(e => e.CategoryName)
.HasDatabaseName("CategoryName");

builder.Property(e => e.CategoryId).HasColumnName("CategoryID")
/*.ValueGeneratedNever()*/;

builder.Property(e => e.CategoryName)
.IsRequired()
.HasMaxLength(15);

builder.Property(e => e.Description).HasColumnType("text");

builder.Property(e => e.Picture).HasColumnType("blob");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using LinqToDB.EntityFrameworkCore.BaseTests.Models.Northwind;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace LinqToDB.EntityFrameworkCore.SQLite.Tests.Models.Northwind.Mapping
{
public class CustomerCustomerDemoMap : IEntityTypeConfiguration<CustomerCustomerDemo>
{
public void Configure(EntityTypeBuilder<CustomerCustomerDemo> builder)
{

builder.HasKey(e => new { e.CustomerId, e.CustomerTypeId });

builder.Property(e => e.CustomerId)
.HasColumnName("CustomerID")
.HasMaxLength(5);

builder.Property(e => e.CustomerTypeId)
.HasColumnName("CustomerTypeID")
.HasMaxLength(10);

builder.HasOne(d => d.Customer)
.WithMany(p => p.CustomerCustomerDemo)
.HasForeignKey(d => d.CustomerId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_CustomerCustomerDemo_Customers");

builder.HasOne(d => d.CustomerType)
.WithMany(p => p.CustomerCustomerDemo)
.HasForeignKey(d => d.CustomerTypeId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_CustomerCustomerDemo");

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using LinqToDB.EntityFrameworkCore.BaseTests.Models.Northwind;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace LinqToDB.EntityFrameworkCore.SQLite.Tests.Models.Northwind.Mapping
{
public class CustomerDemographicsMap : IEntityTypeConfiguration<CustomerDemographics>
{
public void Configure(EntityTypeBuilder<CustomerDemographics> builder)
{
builder.HasKey(e => e.CustomerTypeId);

builder.Property(e => e.CustomerTypeId)
.HasColumnName("CustomerTypeID")
.HasMaxLength(10)
.ValueGeneratedNever();

builder.Property(e => e.CustomerDesc).HasColumnType("text");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using LinqToDB.EntityFrameworkCore.BaseTests.Models.Northwind;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace LinqToDB.EntityFrameworkCore.SqlServer.Tests.Models.Northwind.Mapping
{
public class CustomersMap : IEntityTypeConfiguration<Customer>
{
public void Configure(EntityTypeBuilder<Customer> builder)
{

builder.HasKey(e => e.CustomerId);

builder.HasIndex(e => e.City)
.HasDatabaseName("City");

builder.HasIndex(e => e.CompanyName)
.HasDatabaseName("Customer_CompanyName");

builder.HasIndex(e => e.PostalCode)
.HasDatabaseName("Customer_Postal_ode");

builder.HasIndex(e => e.Region)
.HasDatabaseName("Customer_Region");

builder.Property(e => e.CustomerId)
.HasColumnName("CustomerID")
.HasMaxLength(5)
.ValueGeneratedNever();

builder.Property(e => e.Address).HasMaxLength(60);
builder.Property(e => e.City).HasMaxLength(15);
builder.Property(e => e.CompanyName)
.IsRequired()
.HasMaxLength(40);

builder.Property(e => e.ContactName).HasMaxLength(30);
builder.Property(e => e.ContactTitle).HasMaxLength(30);
builder.Property(e => e.Country).HasMaxLength(15);
builder.Property(e => e.Fax).HasMaxLength(24);
builder.Property(e => e.Phone).HasMaxLength(24);
builder.Property(e => e.PostalCode).HasMaxLength(10);
builder.Property(e => e.Region).HasMaxLength(15);

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using LinqToDB.EntityFrameworkCore.BaseTests.Models.Northwind;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace LinqToDB.EntityFrameworkCore.SQLite.Tests.Models.Northwind.Mapping
{
public class EmployeeTerritoriesMap : IEntityTypeConfiguration<EmployeeTerritory>
{
public void Configure(EntityTypeBuilder<EmployeeTerritory> builder)
{
builder.HasKey(e => new { e.EmployeeId, e.TerritoryId });

builder.Property(e => e.EmployeeId).HasColumnName("EmployeeID");

builder.Property(e => e.TerritoryId)
.HasColumnName("TerritoryID")
.HasMaxLength(20);

builder.HasOne(d => d.Employee)
.WithMany(p => p.EmployeeTerritories)
.HasForeignKey(d => d.EmployeeId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_EmployeeTerritories_Employees");

builder.HasOne(d => d.Territory)
.WithMany(p => p.EmployeeTerritories)
.HasForeignKey(d => d.TerritoryId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_EmployeeTerritories_Territories");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using LinqToDB.EntityFrameworkCore.BaseTests.Models.Northwind;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace LinqToDB.EntityFrameworkCore.SQLite.Tests.Models.Northwind.Mapping
{
public class EmployeesMap : IEntityTypeConfiguration<Employee>
{
public void Configure(EntityTypeBuilder<Employee> builder)
{
builder.HasKey(e => e.EmployeeId);

builder.HasIndex(e => e.LastName)
.HasDatabaseName("Employee_LastName");

builder.HasIndex(e => e.PostalCode)
.HasDatabaseName("Employee_PostalCode");

builder.Property(e => e.EmployeeId).HasColumnName("EmployeeID")
.ValueGeneratedNever();

builder.Property(e => e.Address).HasMaxLength(60);

builder.Property(e => e.BirthDate).HasColumnType("datetime");

builder.Property(e => e.City).HasMaxLength(15);

builder.Property(e => e.Country).HasMaxLength(15);

builder.Property(e => e.Extension).HasMaxLength(4);

builder.Property(e => e.FirstName)
.IsRequired()
.HasMaxLength(10);

builder.Property(e => e.HireDate).HasColumnType("datetime");

builder.Property(e => e.HomePhone).HasMaxLength(24);

builder.Property(e => e.LastName)
.IsRequired()
.HasMaxLength(20);

builder.Property(e => e.Notes).HasColumnType("text");

builder.Property(e => e.Photo).HasColumnType("blob");

builder.Property(e => e.PhotoPath).HasMaxLength(255);

builder.Property(e => e.PostalCode).HasMaxLength(10);

builder.Property(e => e.Region).HasMaxLength(15);

builder.Property(e => e.Title).HasMaxLength(30);

builder.Property(e => e.TitleOfCourtesy).HasMaxLength(25);

builder.HasOne(d => d.ReportsToNavigation)
.WithMany(p => p!.InverseReportsToNavigation)
.HasForeignKey(d => d.ReportsTo)
.HasConstraintName("FK_Employees_Employees");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using LinqToDB.EntityFrameworkCore.BaseTests.Models.Northwind;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace LinqToDB.EntityFrameworkCore.SQLite.Tests.Models.Northwind.Mapping
{
public class OrderDetailsMap : IEntityTypeConfiguration<OrderDetail>
{
public void Configure(EntityTypeBuilder<OrderDetail> builder)
{
builder.HasKey(e => new { e.OrderId, e.ProductId });

builder.ToTable("Order Details");

builder.HasIndex(e => e.OrderId)
.HasDatabaseName("OrdersOrder_Details");

builder.HasIndex(e => e.ProductId)
.HasDatabaseName("ProductsOrder_Details");

builder.Property(e => e.OrderId).HasColumnName("OrderID");

builder.Property(e => e.ProductId).HasColumnName("ProductID");

builder.Property(e => e.Quantity).HasDefaultValue(1);

builder.Property(e => e.UnitPrice).HasColumnType("decimal(13, 4)");

builder.HasOne(d => d.Order)
.WithMany(p => p.OrderDetails)
.HasForeignKey(d => d.OrderId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_Order_Details_Orders");

builder.HasOne(d => d.Product)
.WithMany(p => p.OrderDetails)
.HasForeignKey(d => d.ProductId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_Order_Details_Products");
}
}
}
Loading

0 comments on commit 925055c

Please sign in to comment.