Skip to content

Commit 43f063a

Browse files
committed
Add JetCSharpRuntimeAnnotationCodeGenerator and docs
Introduce JetCSharpRuntimeAnnotationCodeGenerator for design-time annotation support and register it in JetDesignTimeServices. Remove explicit EF Core package versions from the project file. Comment out default "bigint" mapping to match Jet/ACE support. Add copilot-instructions.md with provider-specific guidelines.
1 parent 6e518c8 commit 43f063a

5 files changed

Lines changed: 167 additions & 3 deletions

File tree

.github/copilot-instructions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copilot Instructions
2+
3+
## Project Guidelines
4+
- This project (EntityFrameworkCore.Jet) targets the Microsoft Access Jet/ACE database engine, not SQL Server. Generated SQL, type mappings, and literals must be Jet/ACE-compliant (e.g. decimal/currency instead of bigint, #...# date literals, TIMEVALUE()). Note: Access 2016+ (ACE) does have a native BIGINT (Large Number) type, which is a SIGNED 64-bit integer and cannot hold unsigned values like ulong.MaxValue; unsigned ulong/uint should map to decimal(20,0) to avoid overflow. Provider distinctions are OLE DB / ODBC via the ACE/Jet driver rather than SqlClient. Do not assume SQL Server/T-SQL semantics.
5+
- Jet/Access SQL dialect used in this project does not support COALESCE or NZ. When rewriting queries for Jet, prefer using IIF(<expr> IS NULL, <default>, <expr>) or 'CASE WHEN <expr> IS NULL THEN <default> ELSE <expr> END' instead.
6+
- Deferred enhancement for EntityFrameworkCore.Jet: add ACE engine-version detection so that on Access 2016+ the provider can map to native BIGINT (signed long; unsigned ulong/uint still go to decimal(20,0)) and native DATETIME2, while falling back to decimal(20,0)/legacy datetime on older ACE versions. Not a priority right now.
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
using EntityFrameworkCore.Jet.Metadata.Internal;
2+
using Microsoft.EntityFrameworkCore.Design.Internal;
3+
4+
namespace EntityFrameworkCore.Jet.Design.Internal;
5+
6+
/// <summary>
7+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
8+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
9+
/// any release. You should only use it directly in your code with extreme caution and knowing that
10+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
11+
/// </summary>
12+
#pragma warning disable EF1001 // Internal EF Core API usage.
13+
public class JetCSharpRuntimeAnnotationCodeGenerator : RelationalCSharpRuntimeAnnotationCodeGenerator
14+
{
15+
/// <summary>
16+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
17+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
18+
/// any release. You should only use it directly in your code with extreme caution and knowing that
19+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
20+
/// </summary>
21+
public JetCSharpRuntimeAnnotationCodeGenerator(
22+
CSharpRuntimeAnnotationCodeGeneratorDependencies dependencies,
23+
RelationalCSharpRuntimeAnnotationCodeGeneratorDependencies relationalDependencies)
24+
: base(dependencies, relationalDependencies)
25+
{
26+
}
27+
28+
/// <inheritdoc />
29+
public override void Generate(IModel model, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
30+
{
31+
if (!parameters.IsRuntime)
32+
{
33+
var annotations = parameters.Annotations;
34+
}
35+
36+
base.Generate(model, parameters);
37+
}
38+
39+
/// <inheritdoc />
40+
public override void Generate(IRelationalModel model, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
41+
{
42+
if (!parameters.IsRuntime)
43+
{
44+
var annotations = parameters.Annotations;
45+
}
46+
47+
base.Generate(model, parameters);
48+
}
49+
50+
/// <inheritdoc />
51+
public override void Generate(IProperty property, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
52+
{
53+
/*if (!parameters.IsRuntime)
54+
{
55+
var annotations = parameters.Annotations;
56+
57+
if (!annotations.ContainsKey(JetAnnotationNames.ValueGenerationStrategy))
58+
{
59+
annotations[JetAnnotationNames.ValueGenerationStrategy] = property.GetValueGenerationStrategy();
60+
}
61+
}*/
62+
63+
base.Generate(property, parameters);
64+
}
65+
66+
/// <inheritdoc />
67+
public override void Generate(IColumn column, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
68+
{
69+
if (!parameters.IsRuntime)
70+
{
71+
var annotations = parameters.Annotations;
72+
//annotations.Remove(JetAnnotationNames.Identity);
73+
}
74+
75+
base.Generate(column, parameters);
76+
}
77+
78+
/// <inheritdoc />
79+
public override void Generate(IIndex index, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
80+
{
81+
if (!parameters.IsRuntime)
82+
{
83+
var annotations = parameters.Annotations;
84+
annotations.Remove(JetAnnotationNames.Include);
85+
}
86+
87+
base.Generate(index, parameters);
88+
}
89+
90+
/// <inheritdoc />
91+
public override void Generate(ITableIndex index, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
92+
{
93+
if (!parameters.IsRuntime)
94+
{
95+
var annotations = parameters.Annotations;
96+
annotations.Remove(JetAnnotationNames.Include);
97+
}
98+
99+
base.Generate(index, parameters);
100+
}
101+
102+
/// <inheritdoc />
103+
public override void Generate(IKey key, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
104+
{
105+
if (!parameters.IsRuntime)
106+
{
107+
var annotations = parameters.Annotations;
108+
}
109+
110+
base.Generate(key, parameters);
111+
}
112+
113+
/// <inheritdoc />
114+
public override void Generate(IUniqueConstraint uniqueConstraint, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
115+
{
116+
if (!parameters.IsRuntime)
117+
{
118+
var annotations = parameters.Annotations;
119+
}
120+
121+
base.Generate(uniqueConstraint, parameters);
122+
}
123+
124+
/// <inheritdoc />
125+
public override void Generate(IEntityType entityType, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
126+
{
127+
if (!parameters.IsRuntime)
128+
{
129+
var annotations = parameters.Annotations;
130+
}
131+
132+
base.Generate(entityType, parameters);
133+
}
134+
135+
/// <inheritdoc />
136+
public override void Generate(ITable table, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
137+
{
138+
if (!parameters.IsRuntime)
139+
{
140+
var annotations = parameters.Annotations;
141+
}
142+
143+
base.Generate(table, parameters);
144+
}
145+
146+
/// <inheritdoc />
147+
public override void Generate(IRelationalPropertyOverrides overrides, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
148+
{
149+
if (!parameters.IsRuntime)
150+
{
151+
var annotations = parameters.Annotations;
152+
}
153+
154+
base.Generate(overrides, parameters);
155+
}
156+
}

src/EFCore.Jet/Design/Internal/JetDesignTimeServices.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

33
using EntityFrameworkCore.Jet.Scaffolding.Internal;
4+
using Microsoft.EntityFrameworkCore.Design.Internal;
45

56
namespace EntityFrameworkCore.Jet.Design.Internal
67
{
@@ -24,6 +25,7 @@ public virtual void ConfigureDesignTimeServices(IServiceCollection serviceCollec
2425
#pragma warning disable EF1001 // Internal EF Core API usage.
2526
new EntityFrameworkRelationalDesignServicesBuilder(serviceCollection)
2627
.TryAdd<IAnnotationCodeGenerator, JetAnnotationCodeGenerator>()
28+
.TryAdd<ICSharpRuntimeAnnotationCodeGenerator, JetCSharpRuntimeAnnotationCodeGenerator>()
2729
#pragma warning restore EF1001 // Internal EF Core API usage.
2830
.TryAdd<IDatabaseModelFactory, JetDatabaseModelFactory>()
2931
.TryAdd<IProviderConfigurationCodeGenerator, JetCodeGenerator>()

src/EFCore.Jet/EFCore.Jet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
</ItemGroup>
1717

1818
<ItemGroup Condition="'$(LocalEFCoreRepository)' == ''">
19-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0-rc.2.*" PrivateAssets="none" />
20-
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.0-rc.2.*" PrivateAssets="none" />
19+
<PackageReference Include="Microsoft.EntityFrameworkCore" PrivateAssets="none" />
20+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" PrivateAssets="none" />
2121
</ItemGroup>
2222

2323
<ItemGroup Condition="'$(LocalEFCoreRepository)' != ''">

src/EFCore.Jet/Storage/Internal/JetTypeMappingSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public JetTypeMappingSource(
129129
{"long", [_bigint] },//is this right
130130
{"int", [_integer] },
131131
{"integer4", [_integer] },
132-
{"bigint", [_bigint] },
132+
//{"bigint", [_bigint] },
133133

134134
{"single", [_single] },
135135
{"real", [_single] },

0 commit comments

Comments
 (0)