We are working on Visual Studio Add-ins for U2 Database. It will allow Server Explorer Integration and hence you can use DataSet Designer or EDM Designer. In Server Explorer, you will see Tables, Views and Subroutines. We will go EAP soon.
For now , you can do the following:
- Create empty model.
- From EDM Designer, drop one entity , give some name
- Create two Properties, ID (int) and FirstName (string)
- For example, Student, Students, ID, FirstName
- Now , open the student.edmx file in XML Editor. For example, Right Click on student.edmx file and choose Open With->XML Text Editor
- You will see SSDL, CSDL amd MSL
- CSDL will have entity and two properties
- SSDL and MSL should be Empty
Now replace this line :
Schema xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl" Namespace="Model1.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005"
with
Schema xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl" Namespace="Student.Store" Alias="Self" Provider="U2.Data.Client" ProviderManifestToken="UNIDATA, 07.02.0000"
In SSDL, add the following
<EntityContainer Name="StudentTargetContainer" >
<EntitySet Name="STUDENT" EntityType="Student.Store.STUDENT_NF_SUB" />
</EntityContainer>
<EntityType Name="STUDENT">
<Key>
<PropertyRef Name="ID" />
</Key>
<Property Name="ID" Type="int" Nullable="false" />
<Property Name="FNAME" Type="varchar" MaxLength="25" />
</EntityType>
Save the File.
- Now double click student.edmx file to open in the Designer.
- Time to time, you open student.edmx either in XML editor or EDM Designer.
One content two views
- Open Mapping Details Window. Right click on Entity -> Table Mapping
- Map ID ->ID and FirstName-FNAME
- Open App.config file and add the following
<add name="StudentContainer" connectionString="metadata=res://*/Student.csdl|res://*/Student.ssdl|res://*/Student.msl;provider=U2.Data.Client;provider connection string="Database=demo;User ID=user;Password=pass;Server=localhost;Persist Security Info=True;Pooling=False;ServerType=unidata"" providerName="System.Data.EntityClient"/>
- Open Program.cs file and add this LINQ Query
StudentContainer ctx = new StudentContainer();
var q =ctx.Students.ToList();