Is there a way to set custom pluralizations in EDM designer 2010? - entity-framework

I am using VS 2010 and I have an entity 'Person'.
The pluralization-service turns its plural to 'People', I want it to be Persons.
Is there a place where I can manage the pluralizations library?

Not in Visual Studio, no.
In the meantime though you can drop down to the API level and create your own implementation derived from the abstract PluralizationService class. Once you’ve done this you can tell the EntityModelSchemaGenerator to use your implementation, rather than the default, to produce a model using your particular pluralization rules. This is an API only solution, we don’t yet provide a way to choose a different pluralizer in Visual Studio.
You can use the pluralization service in your own code, however, and customize it there.
Here's an example.

Related

Visual Studio 2013 and Entity Framework

I'm using VS 2013 and SQL Svr 2012 and trying use EF to populate a gridview. As this is a very simple test, I have just one table with a key and a couple of data fields. The process of creating the model seems to work fine - it shows as expected in the designer view, the files are created in app_code, a bin folder is created with 2 dlls, and the config file is updated with a connection string and other entries.
When I try to select the "named connection" I get the error "Unable to load the specified metadata resource" and it talks about rebuilding the project to get the assemblies.
I've spent hours reading other cases like this and I can't understand:
Why this is happening when it was never a problem with VS 2010
How do I fix the connection string to point to the resources it wants. I'm totally lost with all the technical advice about fully qualified assembly names - nothing I try works.
How do I set some parameter to force the resources to be in the proper place? All the advice I've read doesn't seem to relate very well with VS 2013
I need to decide if I should just uninstall VS 2013 and use VS 2012. Currently, I'm using VS 2010 with ASP 4.0 and I'd like to move to ASP 4.5 and generally keep up with Microsoft technology. However, I don't have the skill level to deal with a VS release that is buggy. It seems to me that this EF execise could be due to a either a bug or some odd corruption on my computer - I'm trying to figure out which is the case. I installed VS 2013 Express and SQL Svr 2012 on a clean machine that had none of these tools in the past.
I'd really like to see someone who is very familiar with Visual Studio try to replicate my problem as it only takes a few minutes to do so:
In MS SQL Server, create a tiny DB with one table that has a primary key and a couple of data fields and populate with some test data - Call it TinyDB with TestTable1.
Using VS 2013 Express for Web, create an "New Web Site" with the option for "ASP Empty Web Site" using VB.
Add an ASP App_Code Folder containing an "ADO.Net Entity Data Model" and leave the name as "Model".
Generate the model from the DB and make a "New Connection" for "TinyDB" and using Entity Framework 6.0 and then select "TestTable1". Note the namespace is "TinyDBModel". Clicking "Finish" will generate several items in App_Code, other folders and also update web.config.
Add a web form called default.aspx and drag a gridview onto it. In design mode for the gridview, select "new data source" and then the "Entity" option (note name of EntityDataSource1 which appears in default.aspx). Click next and under "named connection" select "TinyDBEntities" - this is where mine gets the error "Unable to load the specified metadata resource".
Note that this exact exercise in VS 2010 works perfectly and produces a grid with the correct data displayed.
Unfortunately, the EntityDataSource control does not work with the latest version of Entity Framework, EF6. Hopefully the control gets an update in a future update version of VS or EF, but for now you can't use the two together.
There are a few solutions / alternatives:
Drop back to EF 5. In order to do this, delete the .edmx and .tt files from the App_Code folder, delete the EF assemblies from the Bin folder, and remove the references to EF from web.config. Then rebuild the site, add a new ADO.NET Entity Model and choose version 5 in the Choose Your Version dialog. Then delete the .tt files from the App_Code folder, open the EDMX diagam, right-click an empty spot and on the Properties Grid set Code Generation Strategy to Legacy ObjectContext. Then rebuild again, and it should work.
Use Model Binding. This is really the recommended solution. The Microsoft / EF team recommends people to stay away from the EntityDataSource control and only use it for Dynamic Data web sites, Model Binding is the preferred solultion. It's pretty clean and straight forward to use, and gives you a lot of control over your queries and object updates. For more info about Model Binding, check out: http://www.asp.net/web-forms/tutorials/data-access/model-binding/retrieving-data

How to debug Entity Framework Proxies?

After a couple weeks experimenting with Entity Framework 5.0 I think I understand the basics. There's two types of proxies - lazy loading only and change tracking. I know how to enable/disable each and when to use them. However, I want to SEE these classes. I want to be able to step into them at debug time and I want to see what the logic actually does. However, since they are runtime-generated, Visual Studio can't debug them. Ideally I'd be able to pre-compile them, but right now I just want to see what they're doing.
I don't think you can actually debug proxies - at least not using Visual Studio. The types are generated on the fly. The code that generates proxies is here: http://entityframework.codeplex.com/SourceControl/changeset/view/190eef267fc7#src%2fEntityFramework%2fCore%2fObjects%2fInternal%2fEntityProxyFactory.cs (note that this is how it is done in EF6 but it has not changed much since EF5). You may also want to take a look at this blog post: http://davedewinter.com/2010/04/08/viewing-generated-proxy-code-in-the-entity-framework/ - with some hacking you will be able to save generated types to disk and use reflector to see the code.

eUML2 for Eclipse: Association Link Types

I'm trying to find out what different types of association links are available in eUML2 for Eclipse - is there any official documentation which explains it? I've been looking for an hour or so and had no luck so far.
Thanks!
I think eUML2 uses the org.eclipse.uml2 metamodel. If this is true, it should support all association kinds from the UML 2.4 infrastructure. Namely these are Association, Association Class, Composition, Aggregation.
The association is saved in the java code as tags. You can draw associations graphically and see the tag in the code.
There no model explorer visible therefore only the java code can give this association information.

How to integrate my own structural annotations engine in the Entity Framework designer?

In the accepted answer to this SO question there is an explanation about structural annotations, a way to customize the data on the EDMX files generated by the Entity Framework designer. This feature is used by the Portable Extensible Metadata framework in order to add validation information to the entities defined in an EF model, by adding extra entries to the "Properties" window of the created entities and its properties.
My question is: what should I do if I want to create my own custom structural annotations engine? That is, I want Visual Studio to show some extra entries in the properties window for the EF entities; and I want to integrate my own code with the EDMX code generator in order to generate structural annotations. I guess that I need to create a Visual Studio extension but apart from this, I could not find any further information anywhere else. Where should I look for information on this subject?
Entity framework has very low extensibility on ORM layer but it has surprisingly good extensibility on designer layer. The core of extensibility is based on few interfaces which can be implemented to add custom features to EDMX designer as VS extension.
The step by step process of adding custom property to designer is described in Entity Framework 4 in Action book. You can also use Designer Extension Starter Kit to get some prepared templates and kick start for creating your own extensions.
These features targets EFv4. Extension starter kit doesn't work with June 2011 CTP and its new designer.

ActiveReports Upgrade Error

I just upgraded from ActiveReports 2.0 to 3.0. All rpx files have been converted to *.vb files. The ActiveReports project has this class hierarchy:
*.vb with designer -> PrintBase.vb -> ActiveReport3
When I opened any of the *.vb files, I got this error:
The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: xxx --- The base class 'PrintBase' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.
Call stack:
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
Then I went through PrintBase.vb. There was no compile error. Then I modified one of the *.vb files to this:
Hello.vb -> ActiveReport3
The designer worked without any problems. The PrintBase has quite a bit of code. To simplify the debugging, I created a new .vb file called BasePrint that inherits from ActiveReport3. So, the hierarchy is back to:
Hello.vb -> BasePrint -> ActiveReport3
Then I saw the same error above again. It seems like AR3 designer does not allow .vb files to inherit from a base class according to my debugging. But I am not quite sure. BTW, the ActiveReports project is vb.net. There are other C# projects under a VS 2008 project solution. Is the mixing of VB.NET projects and C# have anything to do the miagration / upgrade process?
Thanks.
Indeed, the class-style inheritance was not supported by the upgrade utility in the ActiveReports 3.x designer. However, after an upgrade is complete you should be able to put the base class bad (the way that you described) and the designer should safely ignore it. If you're still having problems try to close the project, do a clean (delete the old assemblies that might be referncing the old PrintBase class) & close visual studio and reopen it again to get a fresh start.
You can find more information about upgrading reports from ActiveReports 2.x to ActiveReports 3.x at the following page: link text
However, it seems you are using inheritince in this case to share some utility methods and maybe some state (e.g. in class-level fields maybe). For this it is best if you have your reports inherit directly from ActiveReport3 and use "BasePrint" as a sort of utility class that your reports call functions in. Normally this has no disadvantage other than having to prefix the method calls with the name of the corresponding BasePrint instance/variable name and it simplifies dealing with ActiveReports designer in the scenario you describe.
However, ActiveReports does support a visual inheritence that allows a base report to share controls with a derived report. There is more information on how to use this feature at the following location: http://www.datadynamics.com/Help/ARNET3/ar3tskInheritance.html. However, I want to stress that this is a different style of inherience than you are using so it may not be applicable to what you need.
Also, you should try to convert again without having a combined solution with C# and VB projects. I don't know that this is a problem but it is certainly not the most common way the converter is used and may be complicating things.
Finally, you should be aware that ActiveReports 6 is now available and you may want to consider trying out that version.
If you continue to have any problems please contact our support team at support#grapecity.us.com or use our public forms that have many ActiveReports experts monitoring them every day at the following links:
http://www.datadynamics.com/forums/73/ShowForum.aspx - ActiveReports 3 Forum
http://www.datadynamics.com/forums/82/ShowForum.aspx - ActiveReports 6 Forum
Scott Willeke
GrapeCity / Data Dynamics