EDMX generated with ODT/ODAC, context class not showing in Domain Service Class - wcf

I am following an msdn walkthrough for creating an RIA services solution with Silverlight. Here is the article link. I have followed at least 4 other articles and found like a dozen more over internet but all of those create edmx from SQL server. In my case, I have to use Oracle in backend, so I have created the data model through Oracle Development Tool, Oracle Provider for .Net.
After generating the edmx and building everything,
I move on to create a domain service class to use the classes in silverlight project, but for some reason the context class doesn't load in the dropdown where it should.
A sample class generated by the edmx looks like this
I have been trying to do this for a week now, and after having been tried for half a dozen times, I need help.

If you are using Visual Studio 2012 have a look here:
http://support.microsoft.com/kb/2745294
In summary:
Open your entity model in the designer (If needed, click in the "white space" of the designer to ensure no objects within the model are selected)
In the Properties window, change the "Code Generation Strategy" from "None" to "Default"
Delete the two ".tt" files that are adjacent to the model, with the assumption that you have not modified these files beyond their original state when the entity model was created. If you have modified these files, then customizations to your entity model will be lost.
Rebuild the project

Related

Thinktecture IdentityManager choosing a db schema

I recently setup a dev site and am using IdentityServer3 with IdentityManager, both from thinktecture, and IdentityManager is designed to create the database for itself, but can be configured to work with an existing db. I was able to get IdentityManager into a local db I had previously created with the default schema, but I would like to switch it to a new schema. Basically the question is that I can't figure out how to set the desired schema in the db in IdentityManager and can anyone in here give any insight?
There are many ways to do this (idsrv3 is very configurable). A common way is to add the MembershipReboot package, subclassing the MembershipReboot factory classes, and then loading your new factories during the idsrv3 startup. You will also need the IdentityServer3.MembershipReboot project, which acts as a go-between between IdentityServer3 and MembershipReboot.
In the visual studio package manager console you add the projects like so:
Install-Package BrockAllen.MembershipReboot
Install-Package IdentityServer3.MembershipReboot
You can use the idsrv3 samples as an example of how to set up your classes. https://github.com/IdentityServer/IdentityServer3.Samples
That will give you the data entities you need. Then to write your entities to a database, add the MembershipReboot.EF project and set up a database connection string that gets passed to your override of the MembershipRebootDbContext() class.
Install-Package BrockAllen.MembershipReboot.Ef
The first time you start your identity server, MembershipReboot.EF will use Entity Framework to automatically create your database schema and start writing your entities there.
Hope that gets you started, sorry if it's not what you're asking!

"Add Project Data Source" from an OData Service does not work

I have created a WCF Data Service (v5.6.0) based on a (model-first) Entity Framework (v5.0) model. I created a new/fresh model to be sure to have all 'defaults' in place (also tried disabling lazy loading but didn't help).
Working
I can now create a Service Reference in a test application (Windows application). From code I can use the generated proxy as if it is the actual model. I can query the data. So far so good.
Wish
However what I would like is to bind my WCF service to a data bound control, e.g. a DataGridView. For this we would like to use the Visual Studio designer so that we can select columns and so on.
Bug?
What I do for this is I click the arrow of the control and then use the "Choose Data Source" dropdown to select "Add Project Data Source" and then select "Service" to create a new service reference. This works without errors. However no data source is created and when I select the arrow again and go to "Choose Data Source" I see absolutely no data source. Also no errors. It gracefully fails.
Am I missing something obvious or is this a bug? Any help will be appreciated.
tnx!

I can't see my model classes

I have an application in MVC4 with Razor and Entity Framework database first.I have a SQL database . Base on this I generated the diagram (edmx) with new Item "ADO.NET Entity Data Model".I choose the database connection,my tables and program has generated a diagram with tables and relationships but I can find the class that must be generated after each choosen table (in solution explorer .For a table student from database i must have the mapping with a class student in my solution ).I want to add some validations .Can somebody tell what I done wrong ?
The EDMX diagram has a "code-behind" file. Click the > beside the .edmx file and you should see a file named the same as the .edmx but ending in .Designer.cs; the classes are defined in the "Entities" region in that file.
Having said that, you should never edit the contents of that file. The code in there is generated from your diagram, so any changes are lost when you alter the data model elsewhere. If you want to add validation attributes to your models, you'll need to create partial declarations somewhere else, and attach metadata classes to them. The accepted answer to this SO question shows what you'll need to do.
You must include the namespace of the EDMX file , you can see that in the properties of the file.
Let's say you create EDMX file in folder Models. in Solution Explorer -> Models -> Model1.edmx -> Model1.tt -> student.cs (this your student table class)

Generating CRUD with entity framework (like DataSets can)

I added am edmx file and a table to my project. How can I get it to generate CRUD operations? I did this in the past where it generated them as stored procs, but cant find the option on the table properties. What did I do wrong?
UPDATE
After fiddling about, I discovered I am confusing my tools. With a DataSet.xsd I can drag a table onto the Dataset Designer and click the *TableName*TableAdapter. If you view the properties window you will see "DeleteCommand, InsertCommand, SelectCommand, UpdateCommand". Is there a way to accomplish this task with Entity Framework too?
(If you have any trouble seeing this you can right click the table in dataset designer > Configure > Advanced options > check "Generate Insert, Update and Delete statements".
Since no one has responded with a method to accomplish the task, then I have to assume the functionality does not exist.

Does nHibernate allow drag and drop automatic class creation like linq to sql?

Just a basic question. Learning Linq to SQL and some nHibernate. I am using the mvc tutorial and they drag and drop tables onto the visual studio designer to create the classes and wire up everything.
When I experimented with nHibernate I had to do lots with xml files. Does nHibernate have anything that is "easy" like Linq to SQL or is this drag and drop for Linq to SQL so basic that when I want to do something "real" it won't matter that Visual Studio does this for me (at this basic level)? In other words, the further I go with Linq to SQL, I'll eventually have to handle config files like I do with nHibernate.
Look at Castle's ActiveRecord framework. It replaces the use of XML config files with the use of Attributes directly on the class/property declaration. Also, a tool called ActiveWriter integrates with Visual Studio and allows connecting to a data source and generating the object model!
There is no "native" support like you see with LINQ to SQL. However, there are third party add-ins that will allow you to do something similar with nHibernate. My favorite is this one:
http://sourceforge.net/projects/nhibernateaddin
To use it:
Create a data connection to a
database that contains the structure
you are going to code against (your
development database).
Add a new NHibernate plug-in item
(via add new item) to your project
that will contain you domain objects.
In the property window add the data
connection string from the data
connection you just created (this
isn't automated yet).
Finally, you drag and drop your tables
from your data connection to the
NHibernate plug-in object and when
saved your mapping files and you
domain objects are generated. To use
it you create a data connection to a
database that contains the structure
you are going to code against (your
development database).