Skip to content

Add ODBC and OLE DB specific packages #74

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<PropertyGroup>
<Product>EntityFrameworkCore.Jet</Product>
<Description>Jet (Microsoft Access mdb or accdb files) provider for Entity Framework Core (EFCore)</Description>
<Authors>Laurents Meyer, Bubi</Authors>
<Company>Bubi</Company>
<Copyright>Copyright © 2017-2020 Bubi</Copyright>
Expand All @@ -13,7 +12,7 @@
<DebugType>portable</DebugType>
<IsPackable>False</IsPackable>
<!-- <PackageReleaseNotes>TODO</PackageReleaseNotes> -->
<PackageTags>Entity Framework Core Jet;Entity Framework Core Access;Entity Framework Core MS Access;entity-framework-core-jet;entity-framework-core-access;entity-framework-core-msaccess;EF Jet;EF Access;EF MS Access;Data;O/RM;EntityFramework;EntityFrameworkCore;EFCore;Jet;Access;MS Access</PackageTags>
<PackageTags>Entity Framework Core;Entity Framework Core;entity-framework-core;Jet;ACE;Access;MS Access;msaccess;EF;EFCore;EF Core;EntityFrameworkCore</PackageTags>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/bubibubi/EntityFrameworkCore.Jet</PackageProjectUrl>
<!-- <PackageIconUrl>TODO</PackageIconUrl> -->
Expand Down
30 changes: 30 additions & 0 deletions EntityFrameworkCore.Jet.sln → EFCore.Jet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ ProjectSection(SolutionItems) = preProject
tools\Resources.tt = tools\Resources.tt
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFCore.Jet.Odbc", "src\EFCore.Jet.Odbc\EFCore.Jet.Odbc.csproj", "{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFCore.Jet.OleDb", "src\EFCore.Jet.OleDb\EFCore.Jet.OleDb.csproj", "{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -145,6 +149,30 @@ Global
{5CD8B47D-E32C-480A-8331-55549EC8E12E}.Release|x64.Build.0 = Release|x64
{5CD8B47D-E32C-480A-8331-55549EC8E12E}.Release|x86.ActiveCfg = Release|x86
{5CD8B47D-E32C-480A-8331-55549EC8E12E}.Release|x86.Build.0 = Release|x86
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Debug|x64.ActiveCfg = Debug|Any CPU
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Debug|x64.Build.0 = Debug|Any CPU
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Debug|x86.ActiveCfg = Debug|Any CPU
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Debug|x86.Build.0 = Debug|Any CPU
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Release|Any CPU.Build.0 = Release|Any CPU
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Release|x64.ActiveCfg = Release|Any CPU
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Release|x64.Build.0 = Release|Any CPU
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Release|x86.ActiveCfg = Release|Any CPU
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A}.Release|x86.Build.0 = Release|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Debug|x64.ActiveCfg = Debug|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Debug|x64.Build.0 = Debug|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Debug|x86.ActiveCfg = Debug|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Debug|x86.Build.0 = Debug|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Release|Any CPU.Build.0 = Release|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Release|x64.ActiveCfg = Release|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Release|x64.Build.0 = Release|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Release|x86.ActiveCfg = Release|Any CPU
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -157,6 +185,8 @@ Global
{3C88D49A-7EF2-42BA-A8D7-9DF7D358FD24} = {6A8DE399-1804-4113-A408-F23B7F5C9CAC}
{770A076B-A448-499C-BB86-A37994C04523} = {6A8DE399-1804-4113-A408-F23B7F5C9CAC}
{5CD8B47D-E32C-480A-8331-55549EC8E12E} = {6A8DE399-1804-4113-A408-F23B7F5C9CAC}
{1E0729DA-B861-46EA-B1F1-3AE20EA1E00A} = {F68095EE-6CD1-43A2-B498-6CA72CE2A0CB}
{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71} = {F68095EE-6CD1-43A2-B498-6CA72CE2A0CB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9359773D-6399-447E-9814-6CB41C2FB664}
Expand Down
1 change: 1 addition & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
<IncludeSymbols>true</IncludeSymbols>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<MinClientVersion>3.6</MinClientVersion>
</PropertyGroup>
</Project>
23 changes: 23 additions & 0 deletions src/EFCore.Jet.Odbc/EFCore.Jet.Odbc.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Explicit ODBC support for Jet/ACE database provider for Entity Framework Core (Microsoft Access MDB/ACCDB files).</Description>
<TargetFramework>$(DefaultNetStandardTargetFramework)</TargetFramework>
<AssemblyName>EntityFrameworkCore.Jet.Odbc</AssemblyName>
<RootNamespace>EntityFrameworkCore.Jet</RootNamespace>
<PackageTags>$(PackageTags);ODBC;System.Data.Odbc</PackageTags>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Shared\*.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EFCore.Jet\EFCore.Jet.csproj" PrivateAssets="contentfiles;build" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Data.Odbc" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Data.Jet;
using System.Data.Odbc;
using EntityFrameworkCore.Jet.Infrastructure;
using JetBrains.Annotations;
using EntityFrameworkCore.Jet.Utilities;

// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
/// <summary>
/// Jet specific ODBC extension methods for <see cref="DbContextOptionsBuilder" />.
/// </summary>
public static class JetOdbcDbContextOptionsBuilderExtensions
{
#region Connection String

/// <summary>
/// Configures the context to connect to a Microsoft Jet database using ODBC.
/// </summary>
/// <param name="optionsBuilder"> The builder being used to configure the context. </param>
/// <param name="fileNameOrConnectionString"> The file name or ODBC connection string of the database to connect
/// to. In case the connection string does not specify an Access driver (ODBC), the highest version of all
/// compatible installed ones is being used. </param>
/// <param name="jetOptionsAction">An optional action to allow additional Jet specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder<TContext> UseJetOdbc<TContext>(
[NotNull] this DbContextOptionsBuilder<TContext> optionsBuilder,
[NotNull] string fileNameOrConnectionString,
[CanBeNull] Action<JetDbContextOptionsBuilder> jetOptionsAction = null)
where TContext : DbContext
=> optionsBuilder.UseJet(fileNameOrConnectionString, DataAccessProviderType.Odbc, jetOptionsAction);

/// <summary>
/// Configures the context to connect to a Microsoft Jet database using ODBC.
/// </summary>
/// <param name="optionsBuilder"> The builder being used to configure the context. </param>
/// <param name="fileNameOrConnectionString"> The file name or ODBC connection string of the database to connect
/// to. In case the connection string does not specify an Access driver (ODBC), the highest version of all
/// compatible installed ones is being used. </param>
/// <param name="jetOptionsAction">An optional action to allow additional Jet specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder UseJetOdbc(
[NotNull] this DbContextOptionsBuilder optionsBuilder,
[NotNull] string fileNameOrConnectionString,
[CanBeNull] Action<JetDbContextOptionsBuilder> jetOptionsAction = null)
=> optionsBuilder.UseJet(fileNameOrConnectionString, DataAccessProviderType.Odbc, jetOptionsAction);

#endregion

#region Connection

/// <summary>
/// Configures the context to connect to a Microsoft Jet database using ODBC.
/// </summary>
/// <typeparam name="TContext"> The type of context to be configured. </typeparam>
/// <param name="optionsBuilder"> The builder being used to configure the context. </param>
/// <param name="connection">
/// An existing <see cref="OdbcConnection" /> to be used to connect to the database. If the connection is in
/// the open state then EF will not open or close the connection. If the connection is in the closed state
/// then EF will open and close the connection as needed.
/// </param>
/// <param name="jetOptionsAction">An optional action to allow additional Jet specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder<TContext> UseJetOdbc<TContext>(
[NotNull] this DbContextOptionsBuilder<TContext> optionsBuilder,
[NotNull] OdbcConnection connection,
[CanBeNull] Action<JetDbContextOptionsBuilder> jetOptionsAction = null)
where TContext : DbContext
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(connection, nameof(connection));

return optionsBuilder.UseJet(connection, jetOptionsAction);
}

/// <summary>
/// Configures the context to connect to a Microsoft Jet database using ODBC.
/// </summary>
/// <param name="optionsBuilder"> The builder being used to configure the context. </param>
/// <param name="connection">
/// An existing <see cref="OdbcConnection" /> to be used to connect to the database. If the connection is in
/// the open state then EF will not open or close the connection. If the connection is in the closed state
/// then EF will open and close the connection as needed.
/// </param>
/// <param name="jetOptionsAction">An optional action to allow additional Jet specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder UseJetOdbc(
[NotNull] this DbContextOptionsBuilder optionsBuilder,
[NotNull] OdbcConnection connection,
[CanBeNull] Action<JetDbContextOptionsBuilder> jetOptionsAction = null)
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(connection, nameof(connection));

return optionsBuilder.UseJet(connection, jetOptionsAction);
}

#endregion
}
}
23 changes: 23 additions & 0 deletions src/EFCore.Jet.OleDb/EFCore.Jet.OleDb.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Explicit OLE DB support for Jet/ACE database provider for Entity Framework Core (Microsoft Access MDB/ACCDB files).</Description>
<TargetFramework>$(DefaultNetStandardTargetFramework)</TargetFramework>
<AssemblyName>EntityFrameworkCore.Jet.OleDb</AssemblyName>
<RootNamespace>EntityFrameworkCore.Jet</RootNamespace>
<PackageTags>$(PackageTags);OLE DB;OLEDB;System.Data.OleDb</PackageTags>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Shared\*.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EFCore.Jet\EFCore.Jet.csproj" PrivateAssets="contentfiles;build" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Data.OleDb" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Data.Jet;
using System.Data.OleDb;
using EntityFrameworkCore.Jet.Infrastructure;
using JetBrains.Annotations;
using EntityFrameworkCore.Jet.Utilities;

// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
/// <summary>
/// Jet specific OLE DB extension methods for <see cref="DbContextOptionsBuilder" />.
/// </summary>
public static class JetOleDbDbContextOptionsBuilderExtensions
{
#region Connection String

/// <summary>
/// Configures the context to connect to a Microsoft Jet database using OLE DB.
/// </summary>
/// <param name="optionsBuilder"> The builder being used to configure the context. </param>
/// <param name="fileNameOrConnectionString"> The file name or OLE DB connection string of the database to connect
/// to. In case the connection string does not specify an Jet/ACE provider (OLE DB), the highest version of all
/// compatible installed ones is being used. </param>
/// <param name="jetOptionsAction">An optional action to allow additional Jet specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder<TContext> UseJetOleDb<TContext>(
[NotNull] this DbContextOptionsBuilder<TContext> optionsBuilder,
[NotNull] string fileNameOrConnectionString,
[CanBeNull] Action<JetDbContextOptionsBuilder> jetOptionsAction = null)
where TContext : DbContext
=> optionsBuilder.UseJet(fileNameOrConnectionString, DataAccessProviderType.OleDb, jetOptionsAction);

/// <summary>
/// Configures the context to connect to a Microsoft Jet database using OLE DB.
/// </summary>
/// <param name="optionsBuilder"> The builder being used to configure the context. </param>
/// <param name="fileNameOrConnectionString"> The file name or OLE DB connection string of the database to connect
/// to. In case the connection string does not specify an Jet/ACE provider (OLE DB), the highest version of all
/// compatible installed ones is being used. </param>
/// <param name="jetOptionsAction">An optional action to allow additional Jet specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder UseJetOleDb(
[NotNull] this DbContextOptionsBuilder optionsBuilder,
[NotNull] string fileNameOrConnectionString,
[CanBeNull] Action<JetDbContextOptionsBuilder> jetOptionsAction = null)
=> optionsBuilder.UseJet(fileNameOrConnectionString, DataAccessProviderType.OleDb, jetOptionsAction);

#endregion

#region Connection

/// <summary>
/// Configures the context to connect to a Microsoft Jet database using OLE DB.
/// </summary>
/// <typeparam name="TContext"> The type of context to be configured. </typeparam>
/// <param name="optionsBuilder"> The builder being used to configure the context. </param>
/// <param name="connection">
/// An existing <see cref="OleDbConnection" /> to be used to connect to the database. If the connection is in
/// the open state then EF will not open or close the connection. If the connection is in the closed state
/// then EF will open and close the connection as needed.
/// </param>
/// <param name="jetOptionsAction">An optional action to allow additional Jet specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder<TContext> UseJetOleDb<TContext>(
[NotNull] this DbContextOptionsBuilder<TContext> optionsBuilder,
[NotNull] OleDbConnection connection,
[CanBeNull] Action<JetDbContextOptionsBuilder> jetOptionsAction = null)
where TContext : DbContext
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(connection, nameof(connection));

return optionsBuilder.UseJet(connection, jetOptionsAction);
}

/// <summary>
/// Configures the context to connect to a Microsoft Jet database using OLE DB.
/// </summary>
/// <param name="optionsBuilder"> The builder being used to configure the context. </param>
/// <param name="connection">
/// An existing <see cref="OleDbConnection" /> to be used to connect to the database. If the connection is in
/// the open state then EF will not open or close the connection. If the connection is in the closed state
/// then EF will open and close the connection as needed.
/// </param>
/// <param name="jetOptionsAction">An optional action to allow additional Jet specific configuration.</param>
/// <returns> The options builder so that further configuration can be chained. </returns>
public static DbContextOptionsBuilder UseJetOleDb(
[NotNull] this DbContextOptionsBuilder optionsBuilder,
[NotNull] OleDbConnection connection,
[CanBeNull] Action<JetDbContextOptionsBuilder> jetOptionsAction = null)
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(connection, nameof(connection));

return optionsBuilder.UseJet(connection, jetOptionsAction);
}

#endregion
}
}
1 change: 1 addition & 0 deletions src/EFCore.Jet/EFCore.Jet.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Jet/ACE database provider for Entity Framework Core (Microsoft Access MDB/ACCDB files).</Description>
<TargetFrameworks>$(DefaultNetStandardTargetFramework);netcoreapp2.1;net461</TargetFrameworks>
<RootNamespace>EntityFrameworkCore.Jet</RootNamespace>
<AssemblyName>EntityFrameworkCore.Jet</AssemblyName>
Expand Down
14 changes: 12 additions & 2 deletions src/EFCore.Jet/Extensions/JetDbContextOptionsBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ public static DbContextOptionsBuilder<TContext> UseJet<TContext>(
[NotNull] string fileNameOrConnectionString,
[CanBeNull] Action<JetDbContextOptionsBuilder> jetOptionsAction = null)
where TContext : DbContext
=> (DbContextOptionsBuilder<TContext>) UseJet((DbContextOptionsBuilder) optionsBuilder, fileNameOrConnectionString, jetOptionsAction);
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotEmpty(fileNameOrConnectionString, nameof(fileNameOrConnectionString));

return (DbContextOptionsBuilder<TContext>) UseJet((DbContextOptionsBuilder) optionsBuilder, fileNameOrConnectionString, jetOptionsAction);
}

/// <summary>
/// Configures the context to connect to a Microsoft Jet database.
Expand Down Expand Up @@ -219,8 +224,13 @@ public static DbContextOptionsBuilder<TContext> UseJet<TContext>(
[NotNull] DbConnection connection,
[CanBeNull] Action<JetDbContextOptionsBuilder> jetOptionsAction = null)
where TContext : DbContext
=> (DbContextOptionsBuilder<TContext>) UseJet(
{
Check.NotNull(optionsBuilder, nameof(optionsBuilder));
Check.NotNull(connection, nameof(connection));

return (DbContextOptionsBuilder<TContext>) UseJet(
(DbContextOptionsBuilder) optionsBuilder, connection, jetOptionsAction);
}

// Note: Decision made to use DbConnection not SqlConnection: Issue #772
/// <summary>
Expand Down
Loading