none
Code First - Database.SetInitializer<CustomerContext>(null) RRS feed

  • Question

  • U2 Toolkit for .NET supports Code First Database First scenario. http://www.rocketsoftware.com/u2/products/u2-net

    For now, we do not support Code First Model First. So we need to put  "Database.SetInitializer<CustomerContext>(null);" in the .NET application.

    Is there any way I can put this (Database.SetInitializer<CustomerContext>(null);) in the  Entity Provider for U2 Database instead of putting in the .NET application?

    Regards,

    Rajan Kumar


    Rajan

    Wednesday, July 11, 2012 4:33 PM

All replies

  • Can you post some code here?
    Sunday, July 15, 2012 2:59 PM
  • When developer uses U2 Toolkit for .NET (LINQ to Entity Code First), they have to do include this line ( Database.SetInitializer<CustomerContext>(null);).

    Can I do something in U2 Toolkit for .NET ( ADO.NET/LINQ to Entity) ?

    If I do not do ( Database.SetInitializer<CustomerContext>(null);), it is very slow.

        class Program
        {
            static void Main(string[] args)
            {

                try
                {
                    Console.WriteLine("start");
                    Database.SetInitializer<CustomerContext>(null);
                    CustomerContext ctx = new CustomerContext();
                    ctx.Configuration.LazyLoadingEnabled = true;

                    var t = ctx.Customers.ToList().Take(5);
                   
                    foreach (Customer item in t)
                    {
                        Console.WriteLine(item.CUSTID + item.FNAME);
                        var q2 = from o in ctx.Orders
                                 where o.CUSTID == item.CUSTID
                                 select o;
                       
                        foreach (var item2 in q2)
                        {
                           
                            Console.WriteLine("\t"+item2.PRODID+"=>"+item2.SER_NUM);
                        }
                       
                    }
                }
                catch (Exception e)
                {
                    if (e.InnerException != null)
                    {
                        Console.WriteLine(e.InnerException.Message);
                    }
                    else
                    {
                        Console.WriteLine(e.Message);
                    }
                   
                }
                finally
                {
                    Console.WriteLine("Enter to exit:");
                    string line = Console.ReadLine();
                }

            }
        }


    Rajan

    Monday, July 16, 2012 3:13 AM
  • Hi Rajan,

    I am trying to plug my VS 2010 to U2 Toolkit and generate model form Universe. How can I do that as I can't find provider name in the list;

    Can I  use IBM data provider as you described in an article in 2009 with U2 Toolkit, as an Add-In for Visual Studio 2010?

    I couldn't find any contact from you so I have to post this question here, sorry for that but it has been a week of late night that I am trying to sort it out...

    Cheers

    Moez

    Thursday, August 23, 2012 2:36 PM