-
Notifications
You must be signed in to change notification settings - Fork 39
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
OleDbException when HasColumnName is not specified #96
Comments
Generally, you code should work, after fixing the Program.csusing System;
using System.Diagnostics;
using System.Linq;
using EntityFrameworkCore.Jet.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace IssueConsoleTemplate
{
public class Cookie
{
public int CookieId { get; set; }
public string Name { get; set; }
public BakingInformation BakingInformation { get; set; }
}
public class BakingInformation
{
public int CookieId { get; set; }
public int DoughWeight { get; set; }
public DateTime BakingTime { get; set; }
}
public class Context : DbContext
{
public DbSet<Cookie> Cookies { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.UseJetOleDb("Data Source=Issue96.accdb")
.UseLoggerFactory(
LoggerFactory.Create(
b => b
.AddConsole()
.AddFilter(level => level >= LogLevel.Information)))
.EnableSensitiveDataLogging()
.EnableDetailedErrors();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Cookie>(
entity =>
{
entity.OwnsOne(
e => e.BakingInformation,
bi => bi.Property(p => p.BakingTime).HasDefaultValueSql("#15:30#"));
});
}
}
internal class Program
{
private static void Main()
{
using (var context = new Context())
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
context.Cookies.AddRange(
new Cookie
{
Name = "Basic",
BakingInformation = new BakingInformation
{
DoughWeight = 35,
}
},
new Cookie
{
Name = "Chocolate Chip",
BakingInformation = new BakingInformation
{
DoughWeight = 40,
BakingTime = JetConfiguration.TimeSpanOffset.AddMinutes(20)
}
}
);
context.SaveChanges();
}
using (var context = new Context())
{
var cookies = context.Cookies
.OrderBy(e => e.CookieId)
.ToList();
Trace.Assert(cookies.Count == 2);
Trace.Assert(cookies[0].CookieId == 1);
Trace.Assert(cookies[0].BakingInformation != null);
Trace.Assert(cookies[0].BakingInformation.DoughWeight == 35);
Trace.Assert(cookies[0].BakingInformation.BakingTime == JetConfiguration.TimeSpanOffset.AddHours(15).AddMinutes(30));
}
}
}
} It runs successfully and generates the following output: EF Core Output
However, while testing the code, I came across an issue, where a single command containing multiple SQL statements (separated by I therefore suggest to fix the syntax error and then give it another try, If it still fails, use the latest daily build and try again. |
Hello my fellow developers! The good stuff at the beginning: I'm having a blast with the current alpha of this provider and my project is moving forward fast, also because of the fast reactions and fixes of all of you.
Today I stumbled over a strange behaviour:
I was defining some entities via the fluent API and defined an owned entity for one of my classes.
I did it like so:
If start the program with this configuration I get the following exception:
System.Data.OleDb.OleDbException: 'Für mindestens einen erforderlichen Parameter wurde kein Wert angegeben.'
If I add the uncommented part with the
HasColumnName
everything works as I would expect it.This not a huge deal because I can just use this function, but it seems like a bug in general.
The text was updated successfully, but these errors were encountered: