CodeFirst and EDM

CodeFirst and EDM

Postby JoeRuspante » Wed 15 Feb 2012 18:27

Hi everybody.

Usually CodeFirst uses reflection for load the definition of the tables during DbContext startup.

When you have a lot of tables, I read that it needs about 300% the time required for EF Database First or Entity First.

Is that problem related only to Microsoft driver, or the same problem is also for dotConnect?

because I need to create a model with a lot of tables, so I have to decide if use Code First (I prefer) or Model First...

Related to that, if I generate the edmx with this instructions:

Code: Select all
                using (DalContext context = new DalContext(new OracleConnection(connBuilder.ToString())))
                    using (var writer = new XmlTextWriter(Settings.Default.EdmxPath, Encoding.Default))
                        EdmxWriter.WriteEdmx(context, writer);

can I tell to DbContext to use the "edmx" generated so it won't use the reflection but read an XML like for EF Model First?

Thank you in advance[/code]
Posts: 54
Joined: Mon 05 Jul 2010 23:08

Postby Shalex » Fri 17 Feb 2012 17:12

1. Please refer to - there are a lot of useful recommendations here.

2. If you have a database with all your tables and you do not need a fluent mapping, you can switch to the usage of XML mapping with DbContext class. We recommend using Entity Developer. It allows to create a model and generate a code with the DbContext template. This is an XML mapping which is set by default in the template. Additionally, you can always switch to the fluent mapping by setting Fluent Mapping=True in the template's properties:
Devart Team
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Return to dotConnect for Oracle