This project has moved and is read-only. For the latest updates, please go here.

WAF with SQL Compact 4? Consulting opportunity?

Jul 29, 2011 at 5:30 PM

I'm wondering if anyone has implemented WAF with SQL C4?

I've used EF4 and C4 before in a WinForms project, with the common work-arounds on the web. I just started on a new WPF project, and having some problems (besides my limited knowledge of WAF and WPF). I've been trying to follow along with C3.5 in the Book Library example. Were some files renamed after generation? Although the file is BookLibraryModel.edmx, the Designer.cs file has just BookLibraryEntities mentioned throughout. I created my with xxxModel.edmx, and all internal references are xxxModelEntities. I think I'm slowly getting my head wrapped around the framework, but the first view with data I added is not working, and I think it's because it's returning a null data for the entity during initialization.

On a related note, is anyone that is experienced with WAF, SQL C4, (C# of course), interested in consulting on a new project over the next week to three? I'm neck deep in a project for a client and could use some help.

Thanks,
Jon

Jul 30, 2011 at 12:07 AM

Some updates for those attempting...

I went back and regenerated it with just BlueANT.edmx and BlueANTEntities.cs.

In your app.config, the connection string will look something like:


<add name="BlueANTEntities" connectionString="metadata=res://*/BlueANT.csdl|res://*/BlueANT.ssdl|res://*/BlueANT.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;Data Source=Resources\BlueANT.sdf;Persist Security Info=True&quot;" providerName="System.Data.EntityClient"/>

You'll need EdmGen2 (Google it from MS). Here's a quick batch file I wrote (adjust for your directory structure):

d:
cd "\Development\Blue Lightning\BlueANT\DesktopClient\BlueANT.Domain"
\Development\EdmGen2\EdmGen2.exe /ModelGen "Data Source=Resources\BlueANT.sdf" System.Data.SqlServerCe.4.0 BlueANT
\Development\EdmGen2\EdmGen2.exe /FromEdmx BlueANT.edmx
\Development\EdmGen2\EdmGen2.exe /Validate BlueANT.edmx
\Development\EdmGen2\EdmGen2.exe /ViewGen cs BlueANT.edmx
\Development\EdmGen2\EdmGen2.exe /CodeGen cs BlueANT.edmx
del obj\Debug\edmxResourcesToEmbed\BlueANT.csdl
del obj\Debug\edmxResourcesToEmbed\BlueANT.msl
del obj\Debug\edmxResourcesToEmbed\BlueANT.ssdl
move BlueANT.csdl obj\Debug\edmxResourcesToEmbed\
move BlueANT.msl obj\Debug\edmxResourcesToEmbed\
move BlueANT.ssdl obj\Debug\edmxResourcesToEmbed\
del BlueANT.Designer.cs
ren BlueANT.cs BlueANT.Designer.cs
pause

EdmGen2 will not (that I've found yet) generate plural entity names, so there's one place (so far) that I've had to update for this, EntityService.cs. Here's a sample:

public ObservableCollection<User> Users
        {
            get 
            {
                if (users == null && entities != null)
                {
                    // We need to call ToArray so that Include will be executed (Eager loading).
                    users = new EntityObservableCollection<User>(entities.User);
                }
                return users;
            }
        }

I've left "Users" everywhere else, but had to use the "entities.User" to refer to the right entity name. Still testing to see if I missed anything else functionality wise. I haven't actually "used" any of the data yet, but I know it's getting created and assigned to the variables. Back to the grind...