diff --git a/Build/linq2db.Default.props b/Build/linq2db.Default.props
index 878a1f4..b433034 100644
--- a/Build/linq2db.Default.props
+++ b/Build/linq2db.Default.props
@@ -1,6 +1,6 @@
- 5.2.1
+ 5.3.0
Svyatoslav Danyliv, Igor Tkachev, Dmitry Lukashenko, Ilya Chudin
Linq to DB
diff --git a/NuGet/linq2db.EntityFrameworkCore.nuspec b/NuGet/linq2db.EntityFrameworkCore.nuspec
index d988332..3c58d58 100644
--- a/NuGet/linq2db.EntityFrameworkCore.nuspec
+++ b/NuGet/linq2db.EntityFrameworkCore.nuspec
@@ -16,7 +16,7 @@
-
+
diff --git a/Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs b/Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs
index 5d87616..ce9383c 100644
--- a/Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs
+++ b/Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs
@@ -158,12 +158,25 @@ public T[] GetAttributes(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;
- }
+ .Any(a =>
+ {
+ if (a.Name.EndsWith(":ValueGenerationStrategy"))
+ return a.Value?.ToString().Contains("Identity") == true;
+
+ if (a.Name.EndsWith(":Autoincrement"))
+ return a.Value is bool b && b;
+
+ // for postgres
+ if (a.Name == "Relational:DefaultValueSql")
+ {
+ if (a.Value is string str)
+ {
+ return str.ToLower().Contains("nextval");
+ }
+ }
+
+ return false;
+ });
var storeObjectId = GetStoreObjectIdentifier(et);
diff --git a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs
index b1f60ce..0caba1e 100644
--- a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs
+++ b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs
@@ -17,6 +17,7 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
+using Microsoft.Extensions.Caching.Memory;
namespace LinqToDB.EntityFrameworkCore
{
@@ -84,10 +85,10 @@ public override int GetHashCode()
#endregion
}
- readonly ConcurrentDictionary _knownProviders = new ConcurrentDictionary();
+ readonly ConcurrentDictionary _knownProviders = new();
- private readonly MemoryCache _schemaCache = new MemoryCache(
- new MemoryCacheOptions
+ private readonly MemoryCache _schemaCache = new(
+ new Microsoft.Extensions.Caching.Memory.MemoryCacheOptions()
{
ExpirationScanFrequency = TimeSpan.FromHours(1.0)
});
diff --git a/Source/LinqToDB.EntityFrameworkCore/linq2db.EntityFrameworkCore.csproj b/Source/LinqToDB.EntityFrameworkCore/linq2db.EntityFrameworkCore.csproj
index e670191..fb1e920 100644
--- a/Source/LinqToDB.EntityFrameworkCore/linq2db.EntityFrameworkCore.csproj
+++ b/Source/LinqToDB.EntityFrameworkCore/linq2db.EntityFrameworkCore.csproj
@@ -23,7 +23,7 @@
-
+
all
diff --git a/Tests/LinqToDB.EntityFrameworkCore.BaseTests/ForMappingTestsBase.cs b/Tests/LinqToDB.EntityFrameworkCore.BaseTests/ForMappingTestsBase.cs
new file mode 100644
index 0000000..7e230e2
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.BaseTests/ForMappingTestsBase.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FluentAssertions;
+using LinqToDB.Data;
+using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping;
+using NUnit.Framework;
+
+namespace LinqToDB.EntityFrameworkCore.BaseTests
+{
+ public abstract class ForMappingTestsBase : TestsBase
+ {
+ public abstract ForMappingContextBase CreateContext();
+
+ [Test]
+ public virtual void TestIdentityMapping()
+ {
+ using var context = CreateContext();
+ using var connection = context.CreateLinqToDbConnection();
+
+ var ed = connection.MappingSchema.GetEntityDescriptor(typeof(WithIdentity));
+ var pk = ed.Columns.Where(c => c.IsPrimaryKey).Single();
+
+ pk.IsIdentity.Should().BeTrue();
+ }
+
+ [Test]
+ public virtual void TestNoIdentityMapping()
+ {
+ using var context = CreateContext();
+ using var connection = context.CreateLinqToDbConnection();
+
+ var ed = connection.MappingSchema.GetEntityDescriptor(typeof(NoIdentity));
+ var pk = ed.Columns.Where(c => c.IsPrimaryKey).Single();
+
+ pk.IsIdentity.Should().BeFalse();
+ }
+
+ [Test]
+ public virtual void TestTableCreation()
+ {
+ using var context = CreateContext();
+ using var connection = context.CreateLinqToDbConnection();
+
+ using var t1 = connection.CreateTempTable();
+ using var t2 = connection.CreateTempTable();
+ }
+
+
+ [Test]
+ public virtual void TestBulkCopyNoIdentity()
+ {
+ using var context = CreateContext();
+ using var connection = context.CreateLinqToDbConnection();
+
+ using var t = connection.CreateTempTable();
+
+ var items = new List()
+ {
+ new() {Id = Guid.NewGuid(), Name = "John Doe"},
+ new() {Id = Guid.NewGuid(), Name = "Jane Doe"}
+ };
+
+ t.BulkCopy(items);
+
+
+ items.Should().BeEquivalentTo(t);
+ }
+
+ [Test]
+ public virtual void TestBulkCopyWithIdentity()
+ {
+ using var context = CreateContext();
+ using var connection = context.CreateLinqToDbConnection();
+
+ using var t = connection.CreateTempTable();
+
+ var items = new List()
+ {
+ new() {Id = 1, Name = "John Doe"},
+ new() {Id = 2, Name = "Jane Doe"}
+ };
+
+ t.BulkCopy(items);
+
+
+ t.Should().HaveCount(items.Count);
+ }
+
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.BaseTests/LinqToDB.EntityFrameworkCore.BaseTests.csproj b/Tests/LinqToDB.EntityFrameworkCore.BaseTests/LinqToDB.EntityFrameworkCore.BaseTests.csproj
index f1adce0..b453528 100644
--- a/Tests/LinqToDB.EntityFrameworkCore.BaseTests/LinqToDB.EntityFrameworkCore.BaseTests.csproj
+++ b/Tests/LinqToDB.EntityFrameworkCore.BaseTests/LinqToDB.EntityFrameworkCore.BaseTests.csproj
@@ -9,6 +9,7 @@
+
diff --git a/Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/ForMappingContextBase.cs b/Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/ForMappingContextBase.cs
new file mode 100644
index 0000000..07bbcce
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/ForMappingContextBase.cs
@@ -0,0 +1,15 @@
+using Microsoft.EntityFrameworkCore;
+
+namespace LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping
+{
+ public abstract class ForMappingContextBase : DbContext
+ {
+ protected ForMappingContextBase(DbContextOptions options) : base(options)
+ {
+ }
+
+ public DbSet WithIdentity { get; set; } = null!;
+ public DbSet NoIdentity { get; set; } = null!;
+
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/NoIdentity.cs b/Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/NoIdentity.cs
new file mode 100644
index 0000000..636bacd
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/NoIdentity.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping
+{
+ public class NoIdentity
+ {
+ public Guid Id { get; set; }
+ public string Name { get; set; } = null!;
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/WithIdentity.cs b/Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/WithIdentity.cs
new file mode 100644
index 0000000..e30c583
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/ForMapping/WithIdentity.cs
@@ -0,0 +1,8 @@
+namespace LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping
+{
+ public class WithIdentity
+ {
+ public int Id { get; set; }
+ public string Name { get; set; } = null!;
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/ForMappingTests.cs b/Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/ForMappingTests.cs
new file mode 100644
index 0000000..4c6ec5b
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/ForMappingTests.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FluentAssertions;
+using LinqToDB.Data;
+using LinqToDB.EntityFrameworkCore.BaseTests;
+using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping;
+using LinqToDB.EntityFrameworkCore.PomeloMySql.Tests.Models.ForMapping;
+using Microsoft.EntityFrameworkCore;
+
+namespace LinqToDB.EntityFrameworkCore.PomeloMySql.Tests
+{
+ public class ForMappingTests : ForMappingTestsBase
+ {
+ public override ForMappingContextBase CreateContext()
+ {
+ var optionsBuilder = new DbContextOptionsBuilder();
+ optionsBuilder.UseMySql("Server=DBHost;Port=3306;Database=TestData;Uid=TestUser;Pwd=TestPassword;charset=utf8;");
+ optionsBuilder.UseLoggerFactory(TestUtils.LoggerFactory);
+
+ var options = optionsBuilder.Options;
+ var ctx = new ForMappingContext(options);
+
+ //ctx.Database.EnsureDeleted();
+ ctx.Database.EnsureCreated();
+
+ return ctx;
+ }
+
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests.csproj b/Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests.csproj
index f6b3f59..544d66a 100644
--- a/Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests.csproj
+++ b/Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests.csproj
@@ -17,8 +17,4 @@
-
-
-
-
diff --git a/Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/Models/ForMapping/ForMappingContext.cs b/Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/Models/ForMapping/ForMappingContext.cs
new file mode 100644
index 0000000..ed5782e
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/Models/ForMapping/ForMappingContext.cs
@@ -0,0 +1,30 @@
+using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping;
+using Microsoft.EntityFrameworkCore;
+
+namespace LinqToDB.EntityFrameworkCore.PomeloMySql.Tests.Models.ForMapping
+{
+ public class ForMappingContext : ForMappingContextBase
+ {
+
+ public ForMappingContext(DbContextOptions options) : base(options)
+ {
+
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity(b =>
+ {
+ b.HasKey(e => e.Id);
+
+ b.Property(e => e.Id)
+ .UseMySqlIdentityColumn();
+ });
+
+ modelBuilder.Entity(b =>
+ {
+ b.HasKey(e => e.Id);
+ });
+ }
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/ForMappingTests.cs b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/ForMappingTests.cs
new file mode 100644
index 0000000..277e5ab
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/ForMappingTests.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FluentAssertions;
+using LinqToDB.Data;
+using LinqToDB.EntityFrameworkCore.BaseTests;
+using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping;
+using LinqToDB.EntityFrameworkCore.PostgreSQL.Tests.Models.ForMapping;
+using Microsoft.EntityFrameworkCore;
+using NUnit.Framework;
+
+namespace LinqToDB.EntityFrameworkCore.PostgreSQL.Tests
+{
+ [TestFixture]
+ public class ForMappingTests : ForMappingTestsBase
+ {
+ public override ForMappingContextBase CreateContext()
+ {
+ var optionsBuilder = new DbContextOptionsBuilder();
+ optionsBuilder.UseNpgsql("Server=DBHost;Port=5432;Database=ForMapping;User Id=postgres;Password=TestPassword;Pooling=true;MinPoolSize=10;MaxPoolSize=100;");
+ optionsBuilder.UseLoggerFactory(TestUtils.LoggerFactory);
+
+ var options = optionsBuilder.Options;
+ var ctx = new ForMappingContext(options);
+
+ //ctx.Database.EnsureDeleted();
+ ctx.Database.EnsureCreated();
+
+ return ctx;
+ }
+
+ //Disabled, we cannot create such identity table.
+ public override void TestBulkCopyWithIdentity()
+ {
+ }
+
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/ForMapping/ForMappingContext.cs b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/ForMapping/ForMappingContext.cs
new file mode 100644
index 0000000..4d1b487
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/ForMapping/ForMappingContext.cs
@@ -0,0 +1,30 @@
+using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping;
+using Microsoft.EntityFrameworkCore;
+
+namespace LinqToDB.EntityFrameworkCore.PostgreSQL.Tests.Models.ForMapping
+{
+ public class ForMappingContext : ForMappingContextBase
+ {
+
+ public ForMappingContext(DbContextOptions options) : base(options)
+ {
+
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity(b =>
+ {
+ b.HasKey(e => e.Id);
+
+ b.Property(e => e.Id)
+ .UseIdentityAlwaysColumn();
+ });
+
+ modelBuilder.Entity(b =>
+ {
+ b.HasKey(e => e.Id);
+ });
+ }
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/IdTests.cs b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/IdTests.cs
index 3f08559..03192b7 100644
--- a/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/IdTests.cs
+++ b/Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/IdTests.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Diagnostics;
using System.Linq;
using FluentAssertions;
@@ -20,7 +20,7 @@ public IdTests()
.ReplaceService()
.UseLoggerFactory(TestUtils.LoggerFactory)
.EnableSensitiveDataLogging()
- .UseNpgsql("Server=DBHost;Port=5432;Database=TestData;User Id=postgres;Password=TestPassword;Pooling=true;MinPoolSize=10;MaxPoolSize=100;")
+ .UseNpgsql("Server=DBHost;Port=5432;Database=IdTests;User Id=postgres;Password=TestPassword;Pooling=true;MinPoolSize=10;MaxPoolSize=100;")
.Options);
_efContext.Database.EnsureDeleted();
_efContext.Database.EnsureCreated();
diff --git a/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/ForMappingTests.cs b/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/ForMappingTests.cs
new file mode 100644
index 0000000..481d0d4
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/ForMappingTests.cs
@@ -0,0 +1,26 @@
+using LinqToDB.EntityFrameworkCore.BaseTests;
+using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping;
+using LinqToDB.EntityFrameworkCore.SQLite.Tests.Models.ForMapping;
+using Microsoft.EntityFrameworkCore;
+using NUnit.Framework;
+
+namespace LinqToDB.EntityFrameworkCore.SQLite.Tests
+{
+ [TestFixture]
+ public class ForMappingTests : ForMappingTestsBase
+ {
+ public override ForMappingContextBase CreateContext()
+ {
+ var optionsBuilder = new DbContextOptionsBuilder();
+ optionsBuilder.UseSqlite("DataSource=:memory:");
+ optionsBuilder.UseLoggerFactory(TestUtils.LoggerFactory);
+
+ var options = optionsBuilder.Options;
+ var ctx = new ForMappingContext(options);
+
+ ctx.Database.EnsureCreated();
+
+ return ctx;
+ }
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests.csproj b/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests.csproj
index c93ae49..a518219 100644
--- a/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests.csproj
+++ b/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests.csproj
@@ -13,10 +13,6 @@
-
-
-
-
diff --git a/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/Models/ForMapping/ForMappingContext.cs b/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/Models/ForMapping/ForMappingContext.cs
new file mode 100644
index 0000000..634131a
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/Models/ForMapping/ForMappingContext.cs
@@ -0,0 +1,30 @@
+using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping;
+using Microsoft.EntityFrameworkCore;
+
+namespace LinqToDB.EntityFrameworkCore.SQLite.Tests.Models.ForMapping
+{
+ public class ForMappingContext : ForMappingContextBase
+ {
+
+ public ForMappingContext(DbContextOptions options) : base(options)
+ {
+
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity(b =>
+ {
+ b.HasKey(e => e.Id);
+
+ b.Property(e => e.Id)
+ .HasAnnotation("Sqlite:Autoincrement", true);
+ });
+
+ modelBuilder.Entity(b =>
+ {
+ b.HasKey(e => e.Id);
+ });
+ }
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/SQLiteTests.cs b/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/SQLiteTests.cs
index ef2ed3b..af110e6 100644
--- a/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/SQLiteTests.cs
+++ b/Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/SQLiteTests.cs
@@ -1,10 +1,7 @@
-using System.Linq;
-using LinqToDB.Data;
+using LinqToDB.Data;
using LinqToDB.EntityFrameworkCore.BaseTests;
-using LinqToDB.EntityFrameworkCore.BaseTests.Models.Northwind;
using LinqToDB.EntityFrameworkCore.SQLite.Tests.Models.Northwind;
using Microsoft.EntityFrameworkCore;
-using NUnit.Framework;
namespace LinqToDB.EntityFrameworkCore.SQLite.Tests
{
@@ -37,21 +34,6 @@ private NorthwindContext CreateSQLiteSqlExntitiesContext()
ctx.Database.EnsureCreated();
return ctx;
}
-
-
- [Test]
- public void TestIdentityMapping()
- {
- using (var ctx = CreateSQLiteSqlExntitiesContext())
- using (var db = ctx.CreateLinqToDbConnection())
- {
- var ed = db.MappingSchema.GetEntityDescriptor(typeof(Category));
- var pk = ed.Columns.Where(c => c.IsPrimaryKey).Single();
-
- Assert.That(pk.IsIdentity, Is.True);
- }
- }
-
}
}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ForMappingTests.cs b/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ForMappingTests.cs
new file mode 100644
index 0000000..85d7c2b
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ForMappingTests.cs
@@ -0,0 +1,27 @@
+using LinqToDB.EntityFrameworkCore.BaseTests;
+using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping;
+using LinqToDB.EntityFrameworkCore.SqlServer.Tests.Models.ForMapping;
+using Microsoft.EntityFrameworkCore;
+using NUnit.Framework;
+
+namespace LinqToDB.EntityFrameworkCore.SqlServer.Tests
+{
+ [TestFixture]
+ public class ForMappingTests : ForMappingTestsBase
+ {
+ public override ForMappingContextBase CreateContext()
+ {
+ var optionsBuilder = new DbContextOptionsBuilder();
+ optionsBuilder.UseSqlServer("Server=.;Database=ForMapping;Integrated Security=SSPI");
+ optionsBuilder.UseLoggerFactory(TestUtils.LoggerFactory);
+
+ var options = optionsBuilder.Options;
+ var ctx = new ForMappingContext(options);
+
+ //ctx.Database.EnsureDeleted();
+ ctx.Database.EnsureCreated();
+
+ return ctx;
+ }
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/IssueTests.cs b/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/IssueTests.cs
index 574f6bb..097a9f9 100644
--- a/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/IssueTests.cs
+++ b/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/IssueTests.cs
@@ -1,4 +1,5 @@
using System.Linq;
+using FluentAssertions;
using LinqToDB.EntityFrameworkCore.BaseTests;
using LinqToDB.EntityFrameworkCore.SqlServer.Tests.Models.IssueModel;
using Microsoft.EntityFrameworkCore;
diff --git a/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Models/ForMapping/ForMappingContext.cs b/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Models/ForMapping/ForMappingContext.cs
new file mode 100644
index 0000000..61fc22b
--- /dev/null
+++ b/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Models/ForMapping/ForMappingContext.cs
@@ -0,0 +1,30 @@
+using LinqToDB.EntityFrameworkCore.BaseTests.Models.ForMapping;
+using Microsoft.EntityFrameworkCore;
+
+namespace LinqToDB.EntityFrameworkCore.SqlServer.Tests.Models.ForMapping
+{
+ public class ForMappingContext : ForMappingContextBase
+ {
+
+ public ForMappingContext(DbContextOptions options) : base(options)
+ {
+
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity(b =>
+ {
+ b.HasKey(e => e.Id);
+
+ b.Property(e => e.Id)
+ .UseIdentityColumn();
+ });
+
+ modelBuilder.Entity(b =>
+ {
+ b.HasKey(e => e.Id);
+ });
+ }
+ }
+}
diff --git a/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ToolsTests.cs b/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ToolsTests.cs
index bd7b606..9387df9 100644
--- a/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ToolsTests.cs
+++ b/Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ToolsTests.cs
@@ -2,6 +2,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using FluentAssertions;
using LinqToDB.Data;
using LinqToDB.EntityFrameworkCore.BaseTests;
using LinqToDB.EntityFrameworkCore.BaseTests.Models.Northwind;
@@ -76,29 +77,7 @@ private NorthwindContext CreateContext(bool enableFilter)
//ctx.Database.EnsureDeleted();
if (ctx.Database.EnsureCreated())
{
-
-
- SetIdentityInsert(ctx, "[dbo].[Employees]", true);
- SetIdentityInsert(ctx, "[dbo].[Categories]", true);
- SetIdentityInsert(ctx, "[dbo].[Orders]", true);
- SetIdentityInsert(ctx, "[dbo].[Products]", true);
- SetIdentityInsert(ctx, "[dbo].[Shippers]", true);
- SetIdentityInsert(ctx, "[dbo].[Suppliers]", true);
-
- try
- {
- NorthwindData.Seed(ctx);
- }
- finally
- {
- SetIdentityInsert(ctx, "[dbo].[Employees]", false);
- SetIdentityInsert(ctx, "[dbo].[Categories]", false);
- SetIdentityInsert(ctx, "[dbo].[Orders]", false);
- SetIdentityInsert(ctx, "[dbo].[Products]", false);
- SetIdentityInsert(ctx, "[dbo].[Shippers]", false);
- SetIdentityInsert(ctx, "[dbo].[Suppliers]", false);
- }
-
+ NorthwindData.Seed(ctx);
}
return ctx;
}
@@ -371,26 +350,6 @@ public void TestAssociations()
}
- [Test]
- public void TestIdentityColumn()
- {
- using (var ctx = CreateContext(false))
- {
- var dependencies = ctx.GetService();
- var mappingSource = ctx.GetService();
- var converters = ctx.GetService();
- var dLogger = ctx.GetService>();
- var ms = LinqToDBForEFTools.GetMappingSchema(ctx.Model, converters, dependencies, mappingSource, dLogger);
-
- var identity = ms.GetAttribute(typeof(Customer),
- MemberHelper.MemberOf(c => c.CustomerId));
-
- //TODO:
- //Assert.NotNull(identity);
- //Assert.AreEqual(true, identity.IsIdentity);
- }
- }
-
[Repeat(2)]
[Test]
public void TestGlobalQueryFilters([Values(true, false)] bool enableFilter)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index a0b5673..fb1b1aa 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -1,8 +1,8 @@
variables:
solution: 'linq2db.EFCore.sln'
build_configuration: 'Release'
- assemblyVersion: 5.2.1
- nugetVersion: 5.2.1
+ assemblyVersion: 5.3.0
+ nugetVersion: 5.3.0
artifact_nugets: 'nugets'
# build on commits to important branches (master + release branches):