I have a problem with the type mapping during a "code first" database creation
All my bool (Boolean) type attributes are mapped to a Number(22) type (also all int fields).
According to this list Boolean ist mapped to NUMBER(1), but not in my case.
https://www.devart.com/dotconnect/oracl ... pping.html
Am i missing something ? Is this the wrong type mapping table i´m refering to ?
As far as i understand it there is also no way to change the type mapping for "code first" ?
code first: bool type mapping problem
Re: code first: bool type mapping problem
Please try the following code in the newly created console application with the newest (8.5.558) build of dotConnect for Oracle:
App.config
Program.cs
The dbMonitor tool shows the following SQL statements sent to the server:
Please tell us how we should modify the code to reproduce the issue.
App.config
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<providers>
<provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity, Version=8.5.558.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="Devart.Data.Oracle" />
<add name="dotConnect for Oracle" invariant="Devart.Data.Oracle" description="Devart dotConnect for Oracle" type="Devart.Data.Oracle.OracleProviderFactory, Devart.Data.Oracle, Version=8.5.558.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="MyDbContext" connectionString="server=orcl1120;uid=scott;pwd=tiger;" providerName="Devart.Data.Oracle"/>
</connectionStrings>
</configuration>
Code: Select all
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication {
class Program {
static void Main(string[] args) {
var monitor = new Devart.Data.Oracle.OracleMonitor() { IsActive = true };
using (var context = new MyDbContext()) {
context.Database.Initialize(true);
}
}
}
public class MyDbContext : DbContext {
public DbSet<C1> C1s { get; set; }
}
[System.ComponentModel.DataAnnotations.Schema.Table("C1")]
public class C1 {
[System.ComponentModel.DataAnnotations.Key]
public int Id { get; set; }
public bool BoolProperty { get; set; }
}
}
Code: Select all
CREATE TABLE C1 (
"Id" NUMBER(10) NOT NULL,
"BoolProperty" NUMBER(1) NOT NULL,
CONSTRAINT PK_C1 PRIMARY KEY ("Id")
)
/
CREATE SEQUENCE C1_SEQ
/
CREATE OR REPLACE TRIGGER C1_INS_TRG
BEFORE INSERT ON C1
FOR EACH ROW
BEGIN
SELECT C1_SEQ.NEXTVAL INTO :NEW."Id" FROM DUAL;
END;
-
- Posts: 16
- Joined: Mon 22 Jun 2015 08:38
Re: code first: bool type mapping problem
Ok, thanks for your investigation. I found the reason. The devart provider is not the problem.
Actually oracle tricked me. The wrong type is only shown in my sql select of the database structure.
I looked for the data_length attribute but number types length is shown in data_precision.
This doesn´t make a sense. Damn why is oracle always such a pain.
Actually oracle tricked me. The wrong type is only shown in my sql select of the database structure.
Code: Select all
select COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION from user_tab_columns order by DATA_TYPE;
This doesn´t make a sense. Damn why is oracle always such a pain.