Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use EFCore 3.1 #335

Merged
merged 101 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
99fc0e6
Copied EntityFramework project as a base for new EFCore project
lindellhugo Oct 19, 2021
cfe6736
Remove not needed DB context
lindellhugo Oct 19, 2021
4068cde
Added todo and added EF Core to test project EFCodeCoreFirstModel
lindellhugo Oct 19, 2021
6519ffa
Made everything compile.
lindellhugo Oct 20, 2021
cd1d9d9
WIP First EF Core Test that compiles (BusinessLogicClass_Context_EFCo…
lindellhugo Oct 22, 2021
b589a23
Rename
lindellhugo Oct 25, 2021
8e2a4b2
All compiles
lindellhugo Oct 25, 2021
0fed1fa
Rename
lindellhugo Oct 25, 2021
15ab71c
Added adwenture works
lindellhugo Oct 25, 2021
13abc5c
Builds
lindellhugo Nov 1, 2021
d2a933d
Schaffolded AdventureWorksDB context model
lindellhugo Nov 1, 2021
8a91c92
Namespace rename
lindellhugo Nov 1, 2021
3ea3e3e
Scaffolded Northwind DB-context
lindellhugo Nov 1, 2021
57ff61f
WIP
lindellhugo Nov 8, 2021
dfa9903
Prepare EFcore project for netstandard, target EF6 instead of EF4 for…
Daniel-Svensson Feb 15, 2022
56ac2ce
Recreate EFCoreModel and remove some of the efcore models
Daniel-Svensson Feb 15, 2022
70d881a
Add some TODO code/docs to type descriptor
Daniel-Svensson Feb 15, 2022
fbb0397
Update projects since files where removed
Daniel-Svensson Feb 15, 2022
37dc97e
Add Ef Core to tests web project so it can create missing binding red…
Daniel-Svensson Feb 15, 2022
f6c2c96
Update test Uri's
Daniel-Svensson Feb 15, 2022
b153c57
Fix resources and make smalles possible change to get typedescriptor …
Daniel-Svensson Feb 15, 2022
133c9c1
Match existing releationship names
Daniel-Svensson Feb 15, 2022
77d8917
setup some basic functionality of EF core type descriptor
Daniel-Svensson Feb 16, 2022
458bb63
fix compilation of tests after namespace change
Daniel-Svensson Feb 16, 2022
dd21d19
fix xml namespace
Daniel-Svensson Feb 16, 2022
ecff498
Fix connectionstring in update tests
Daniel-Svensson Feb 16, 2022
3a87721
Discover some more attributes
Daniel-Svensson Feb 16, 2022
b3b157a
ignore "calculated properties" from partial classes
Daniel-Svensson Feb 16, 2022
be1f8b6
Model updates to better match EF6 models,
Daniel-Svensson Feb 17, 2022
1c0d9bf
Add throw with details about missing code in SetChangeSetConflicts
Daniel-Svensson Feb 17, 2022
ea707eb
Fix compilation
Daniel-Svensson Feb 17, 2022
6428100
Remove extra classes we only need one type of DomainService and Attri…
Daniel-Svensson Feb 17, 2022
80721ab
Add some missing ConcurrencyCheck s
Daniel-Svensson Feb 17, 2022
bc66ad1
merge
Daniel-Svensson Feb 17, 2022
22d0cbf
add some code which might work
Daniel-Svensson Feb 17, 2022
ba9351c
copy baseline from EFCodeFirst for codegen test
Daniel-Svensson Feb 18, 2022
464e2cc
Attempt at finding foreign key members in TypeDescriptor
Daniel-Svensson Feb 18, 2022
c72bd7a
Fix AttachAsModifiedInternal
Daniel-Svensson Feb 18, 2022
382cef3
fix running test on low ram
Daniel-Svensson Feb 18, 2022
5e78301
fix NRE in SetChangeSetConflicts and add code for EnumerateAsync and
Daniel-Svensson Feb 18, 2022
ca3607a
add more missing concurrencytoken (for product)
Daniel-Svensson Feb 19, 2022
e494fc4
increase timeout for debugging client tests
Daniel-Svensson Feb 19, 2022
206e846
handle EFCore same as EF in update tests
Daniel-Svensson Feb 19, 2022
3685ca8
Fix "KeepKurrent" logic
Daniel-Svensson Feb 19, 2022
55e6622
create nupkg on build
Daniel-Svensson Feb 19, 2022
2567b67
Remove unneeded classes from EFCore adventureworks
Daniel-Svensson Feb 19, 2022
fbcbfee
delete unused code
Daniel-Svensson Feb 19, 2022
3552474
fix reverse associations
Daniel-Svensson Feb 20, 2022
c07c6bd
sql table ProductSubcategoryId was empty so change linq query to work…
Daniel-Svensson Feb 20, 2022
040efbb
Remove some unused code
Daniel-Svensson Feb 21, 2022
d67e0fb
Remove some file and link in some others to prevent duplicates
Daniel-Svensson Feb 21, 2022
cff4187
add catalog codegen test
Daniel-Svensson Feb 23, 2022
231429c
updates to adventureworks model
Daniel-Svensson Feb 23, 2022
c1c3e4c
update efcore namespace and merge DbDomainServices into one shared file
Daniel-Svensson Mar 15, 2022
5bc2f11
fix test when autotedectchanges is false
Daniel-Svensson Mar 15, 2022
e397ec7
Add codegen test for EF Core.
lindellhugo Mar 16, 2022
402f80a
Delete BackupDB.ps1
Daniel-Svensson Apr 1, 2022
a83d467
allow passing in dbcontext in ctor
Daniel-Svensson Apr 1, 2022
6a75bf4
Move property descriptors outside the loop
lindellhugo Apr 4, 2022
8dfe4e7
Remove reference
lindellhugo Apr 4, 2022
ddd4f51
Remove unused methods.
lindellhugo Apr 4, 2022
a8145ee
Removed metadataResource
lindellhugo Apr 4, 2022
f7fa522
Remove unused properties.
lindellhugo Apr 4, 2022
5b31ddd
Removed unused folder
lindellhugo Apr 4, 2022
ac48eea
Use on file
lindellhugo Apr 6, 2022
58a4ad5
Fix TODO and introduce tests
lindellhugo Apr 6, 2022
b46ce13
Fix test due to change in resource name
lindellhugo Apr 7, 2022
bc815ed
Add concurrency to ShipVia
lindellhugo Apr 7, 2022
e40e98c
Fix only FK constraints failing in test.
lindellhugo Apr 7, 2022
2ad4350
Update test file
lindellhugo Apr 8, 2022
fb4958e
Remove test.
lindellhugo Apr 8, 2022
8a7f5e0
Update vb file
lindellhugo Apr 8, 2022
6f25e80
WIP
lindellhugo Apr 25, 2022
92a4f68
Updated tests
lindellhugo Apr 26, 2022
fd11c63
Fix test.
lindellhugo Apr 26, 2022
bc19afe
Remove TODO
lindellhugo Apr 27, 2022
8baecfb
Fix tests
lindellhugo Apr 27, 2022
e284beb
Fix todo
lindellhugo Apr 27, 2022
0b4c8c1
Comment out
lindellhugo Apr 27, 2022
fca95b0
Use git diff.
lindellhugo Apr 27, 2022
c0db04f
Merge branch 'main' into use_EFCORE_3_1
lindellhugo Apr 27, 2022
22992e7
Fix merge
lindellhugo Apr 27, 2022
005d5b0
Add end project tag
lindellhugo Apr 29, 2022
91e2f11
Move EFCore model to Test folder
lindellhugo Apr 29, 2022
324e60e
Fix merge error in web.config
lindellhugo Apr 29, 2022
de73c04
Revert to internal
lindellhugo Apr 29, 2022
a928fb5
Remove todo
lindellhugo Apr 29, 2022
98252a0
Fx merge
lindellhugo Apr 29, 2022
664413d
Fix binding redirects.
lindellhugo May 2, 2022
adbf572
- Always refer to latest EF core
Daniel-Svensson May 4, 2022
7946d9f
remove some unneeded references
Daniel-Svensson May 4, 2022
8ae297f
remove "OldAssert"
Daniel-Svensson May 4, 2022
255126c
Fix some TODO and commented out code, checks IsOwned now in a number …
Daniel-Svensson May 5, 2022
39acd06
Use EfCore 3.1.24
Daniel-Svensson May 5, 2022
b671750
Remove pubilc update of resx
lindellhugo May 9, 2022
6bc9035
Remove net 472
lindellhugo May 9, 2022
e01b3b2
Some sonarqube fixes
lindellhugo May 9, 2022
2764ec6
More sonarqube
lindellhugo May 9, 2022
4725e82
Better todo
lindellhugo May 6, 2022
ef54e1a
Fix todo
lindellhugo May 6, 2022
9660204
Remove debug constant
lindellhugo May 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ protected virtual ChannelFactory<TContract> CreateChannelFactory<TContract>(Uri
{
// in debug mode set the timeout to a higher number to
// facilitate debugging
factory.Endpoint.Binding.OpenTimeout = TimeSpan.FromMinutes(5);
factory.Endpoint.Binding.OpenTimeout = TimeSpan.FromMinutes(10);
factory.Endpoint.Binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
factory.Endpoint.Binding.SendTimeout = TimeSpan.FromMinutes(10);
}
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public void TestLoad_WithParameters()
});
EnqueueCallback(delegate
{
Assert.IsTrue(catalog.Products.Count == 8);
Assert.AreEqual(8, catalog.Products.Count);
});
EnqueueTestComplete();
}
Expand Down Expand Up @@ -584,4 +584,44 @@ protected override Northwind CreateNorthwind()
return new Northwind(TestURIs.DbCtx_Northwind);
}
}

[TestClass]
public class EFCoreQueryTests : CrossDomainServiceQueryTests
{
public EFCoreQueryTests()
: base(TestURIs.EFCore_Catalog, ProviderType.EFCore)
{
}

protected override Northwind CreateNorthwind()
{
return new Northwind(TestURIs.EFCore_Northwind);
}

/// <summary>
/// Test queries on projected FK members to make sure they work
/// </summary>
[TestMethod]
[Asynchronous]
public void TestFKProjectionQuery()
{
Catalog catalog = new Catalog(TestURIs.EFCore_Catalog);
LoadOperation lo1 = catalog.Load(catalog.GetEmployeesQuery(), false);

// test both Where and OrderBy expressions involving projected members
LoadOperation lo2 = catalog.Load(catalog.GetPurchaseOrdersQuery().Where(p => p.EmployeeID > 5).OrderBy(p => p.EmployeeID).Take(1), false);

EnqueueConditional(delegate
{
return !catalog.IsLoading;
});
EnqueueCallback(delegate
{
Assert.IsFalse(lo1.HasError || lo2.HasError);
Assert.IsTrue(catalog.Employees.Count > 0, "catalog.Employees.Count should be greater than 0");
Assert.IsTrue(catalog.PurchaseOrders.Count > 0, "catalog.PurchaseOrders.Count should be greater than 0");
});
EnqueueTestComplete();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ public enum ProviderType
/// <summary>
/// Unspecified, non-DAL provider
/// </summary>
Unspecified
Unspecified,

/// <summary>
/// EF Core Linq to SQL provider
/// </summary>
EFCore
}

/// <summary>
Expand Down
41 changes: 33 additions & 8 deletions src/OpenRiaServices.Client/Test/Client.Test/Data/UpdateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ public void SimpleUpdateDeleteConflict()
this.EnqueueCompletion(() => so2);
EnqueueCallback(delegate
{
Assert.AreEqual(Resource.DomainContext_SubmitOperationFailed_Conflicts, so2.Error.Message);
Assert.AreEqual(Resource.DomainContext_SubmitOperationFailed_Conflicts, so2.Error?.Message);
Entity[] entitiesInConflict = so2.EntitiesInError.ToArray();
Assert.AreEqual(1, so2.ChangeSet.RemovedEntities.Count, "Unexpected amount of removed entities.");
Assert.AreEqual(1, entitiesInConflict.Length, "Unexpected amount of entities in conflict.");
Expand Down Expand Up @@ -3077,7 +3077,7 @@ public virtual void ResolveTest_DeleteUpdateConflict_Bug597087()
Assert.IsInstanceOfType(so.Error, typeof(DomainOperationException));
DomainOperationException ex = so.Error as DomainOperationException;

Assert.AreEqual(Resource.DomainContext_SubmitOperationFailed_Conflicts, so.Error.Message);
Assert.AreEqual(Resource.DomainContext_SubmitOperationFailed_Conflicts, so.Error?.Message);
Assert.AreEqual(1, so.EntitiesInError.Count());
EntityConflict conflict = so.EntitiesInError.Single().EntityConflict;
Assert.IsTrue(conflict.IsDeleted);
Expand Down Expand Up @@ -3148,7 +3148,7 @@ public virtual void ResolveTest_MultipleInstances_MixedResolveMethods()
EnqueueCallback(delegate
{
Product[] products = nw2.Products.ToArray();
if (this.ProviderType == ProviderType.EF)
if (this.ProviderType == ProviderType.EF || ProviderType == ProviderType.EFCore)
{
// Verify Product0 changes was not synced back to the client since resubmit still fails with conflict
Assert.IsNull(products[0].EntityConflict);
Expand Down Expand Up @@ -3200,7 +3200,7 @@ public virtual void ResolveTest_MultipleInstances_MixedResolveMethods()
delegate
{
Product[] products = nw1.Products.ToArray();
if (this.ProviderType == ProviderType.EF)
if (this.ProviderType == ProviderType.EF || ProviderType == ProviderType.EFCore)
{
// verify nw2 changes are not persisted
Assert.AreEqual(nw1NewUnitPrice[0], products[0].UnitPrice);
Expand Down Expand Up @@ -3283,7 +3283,7 @@ public virtual void ResolveTest_MultipleInstances_ReturnTrueFalse()

Product[] products = nw2.Products.ToArray();
EntityConflict conflict = null;
if (this.ProviderType == ProviderType.EF)
if (this.ProviderType == ProviderType.EF || ProviderType == ProviderType.EFCore)
{
// EF only supports getting the first conflict so only Product0's conflicts will be generated and only
// its resolve method is called. Hence the conflict is resolved successfully the first round. When resubmit
Expand Down Expand Up @@ -3387,7 +3387,7 @@ public virtual void ResolveTest_MultipleInstances_ReturnTrueTrue()
EnqueueCallback(delegate
{
Product[] products = nw2.Products.ToArray();
if (this.ProviderType == ProviderType.EF)
if (this.ProviderType == ProviderType.EF || ProviderType == ProviderType.EFCore)
{
// EF only supports getting the first conflict so only Product0's conflicts will be generated and only
// its resolve method is called. Hence the conflict is resolved successfully the first round. When resubmit
Expand Down Expand Up @@ -3433,7 +3433,7 @@ public virtual void ResolveTest_MultipleInstances_ReturnTrueTrue()
delegate
{
Product[] products = nw1.Products.ToArray();
if (ProviderType == ProviderType.EF)
if (ProviderType == ProviderType.EF || ProviderType == ProviderType.EFCore)
{
// verify store values are not changed since submit failed
Assert.AreEqual(nw1NewUnitPrice[0], products[0].UnitPrice);
Expand Down Expand Up @@ -3584,7 +3584,7 @@ public virtual void ResolveTest_MultipleInstances_FirstSucceedsSecondThrows()
DomainOperationException ex = so.Error as DomainOperationException;

Product[] products = nw2.Products.ToArray();
if (this.ProviderType == ProviderType.EF)
if (this.ProviderType == ProviderType.EF || ProviderType == ProviderType.EFCore)
{
// EF only supports getting the first conflict, so Product0's conflicts will be generated during first submit,
// then they are resolved server side and resubmit is called. Product1's conflicts will then be generated. Since
Expand Down Expand Up @@ -4473,6 +4473,31 @@ TestContext testContext

}

[TestClass]
public class EFCoreUpdateTests : UpdateTests
{
public EFCoreUpdateTests()
: base(TestURIs.EFCore_Northwind_CUD, ProviderType.EFCore)
{
}

/// <summary>
/// Silverlight version of class initializer doesn't take TestContext
/// </summary>
[ClassInitialize]
public static void ClassSetup(
#if !SILVERLIGHT
TestContext testContext
#endif
)
{
// ensure that our isolation DB has been created once and only once
// at the test fixture level
TestDatabase.Initialize();
}

}

[TestClass]
public class DbCtxUpdateTests : UpdateTests
{
Expand Down
7 changes: 6 additions & 1 deletion src/OpenRiaServices.Client/Test/Client.Test/TestUris.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ public static class TestURIs
public static readonly Uri DbCtx_Northwind_CUD = new Uri(RootURI, "TestDomainServices-DbCtx-Northwind_CUD.svc");
public static readonly Uri DbCtx_Northwind = new Uri(RootURI, "TestDomainServices-DbCtx-Northwind.svc");
public static readonly Uri DbCtx_Catalog = new Uri(RootURI, "TestDomainServices-DbCtx-Catalog.svc");
public static readonly Uri EFCodeFirst = new Uri(RootURI, "EFCodeFirst-EFCodeFirstTestDomainService.svc");
public static readonly Uri EFCodeFirst = new Uri(RootURI, "EFCodeFirst-EFCodeFirstTestDomainService.svc");

// EF Core
public static readonly Uri EFCore_Northwind = new Uri(RootURI, "TestDomainServices-EFCore-Northwind.svc");
public static readonly Uri EFCore_Northwind_CUD = new Uri(RootURI, "TestDomainServices-EFCore-Northwind_CUD.svc");
public static readonly Uri EFCore_Catalog = new Uri(RootURI, "TestDomainServices-EFCore-Catalog.svc");

// LTS
public static readonly Uri LTS_Catalog = new Uri(RootURI, "TestDomainServices-LTS-Catalog.svc");
Expand Down
Loading