EF6 Code First

EF6 Code First

Postby christian_bertram » Thu 30 Jul 2015 09:25

Hi, i dont know if this is a task of the Entity Framework or the dotConnect Provider:

I have a problem with Generating my Oracle tables via code first.
Referenced tables are generated correctly with the Add-Migration functionality. (Initial Migration)
Non-Referenced tables are missing in the generated Migration. I always have to make a reference to another table. But of course there are control tables without any reference, so any idea what is the solution here ?

Thanks.
christian_bertram
 
Posts: 16
Joined: Mon 22 Jun 2015 08:38

Re: EF6 Code First

Postby christian_bertram » Thu 30 Jul 2015 14:12

Ok i still dont know if this is based on a dotconnect bug or entityframework but i could solve it by adding an extra line with the fluent api to the OnModelCreating method

Code: Select all
modelBuilder.Entity<TABLENAME>().ToTable("TABLENAME");


it was not possible to force the generation with data annotation
Code: Select all
[Table("TABLENAME")]
christian_bertram
 
Posts: 16
Joined: Mon 22 Jun 2015 08:38

Re: EF6 Code First

Postby Shalex » Fri 31 Jul 2015 16:22

This code creates the TABLENAME table in the database:
Code: Select all
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(false);
            }
        }
    }

    class MyDbContext : DbContext {

        public MyDbContext()
            : base(new Devart.Data.Oracle.OracleConnection("server=***;uid=***;pwd=***;"), true) { }

        static MyDbContext() {
          DbConfiguration.SetConfiguration(new Devart.Data.Oracle.Entity.OracleEntityProviderServicesConfiguration());
        }

        DbSet<MyClass> myClasses { get; set; }
    }

    [System.ComponentModel.DataAnnotations.Schema.Table("TABLENAME")]
    class MyClass {
        public int Id { get; set; }
        public string data { get; set; }
    }
}

If this doesn't help to fix the problem, please send us a small test project for reproducing the issue you have encountered.
Shalex
Devart Team
 
Posts: 7616
Joined: Thu 14 Aug 2008 12:44

Re: EF6 Code First

Postby christian_bertram » Mon 03 Aug 2015 11:33

I tried the "Table"-tag but it didn´t work.
christian_bertram
 
Posts: 16
Joined: Mon 22 Jun 2015 08:38

Re: EF6 Code First

Postby Shalex » Mon 03 Aug 2015 13:15

Have you tried running our code (without changes, except connection string) in the brand new test project? Notify us about the result.
Shalex
Devart Team
 
Posts: 7616
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle