SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search


EntityFramework Tutorial in SharpDevelop 4.0 Beta 3


Hi there!

Here a short overview of the SharpDevelop 4.0 Beta 3 EF integration - the photo story below is also available as YouTube screencast.:

  1. Create a new project

  2. Create a new Entity Framework Data Model

  3. Create a new database connection

  4. Copy connection string to clipboard

  5. Choose database objects for EDM

    Tables, views and procedures to import can be chosen in this screen
    Model namespace and object context name define how you access the generated code

  6. Close Designer.cs file and don't save it (should be fixed in the future)

  7. Playing around in EDM designer

  8. Changing "BirthDate" property for demo purposes and save the file to generate Designer.cs file

  9. Add "app.config" file for connection string

    Now paste the copied connection string into the connectionStrings section of the new app.config file:   

            <add name="AdventureWorksObjectContext" 
                 connectionString="metadata=res://*/AdventureWorksModel.csdl|res://*/AdventureWorksModel.ssdl|res://*/AdventureWorksModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=PHIL-PC;Initial Catalog=AdventureWorks;Integrated Security=True;MultipleActiveResultSets=True&quot;" 
                 providerName="System.Data.EntityClient" />

  10. Ready to go!

    Simply paste the following code into the Main method of your application:

                AdventureWorksObjectContext context = new AdventureWorksObjectContext();
                foreach (Employee employee in context.Employee)

  11. Now compile and run the program!

Hope you enjoy it! ;)



sym1987 said:


I haven't try the latest beta of SD. Does it support for entity name pluralization?

And it doesn't support the dot (., dot means the local machine, just like server=.;uid=sa;pwd=xxx) as datasource in the last beta.

September 30, 2010 5:31 AM

Michael Seeger said:

Hi Philipp,

when will the Mapping be available? In the sources I encountered that it is not  implemented, yet (neither in 4.0 nor in 4.1beta) although the complete infrastructure is already there ...



August 22, 2011 5:08 PM

erkape said:

Hi Philipp,

when I clicked the finish button, I got an error saying that it cannot create the edmx file. I am using SharpDevelop 4.2, I tried every .Net version and the results are the same. And I'm using Sql Server Express 2008.

Here is the error :

ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters.ObjectModelConverterException: An error occured during generating the EDMX file from "C:\Users\erkape\AppData\Local\Temp\tmpD5E.ssdl".

  at ICSharpCode.Data.EDMDesigner.Core.ObjectModelConverters.EDMConverter.CreateEDMXFromIDatabase(IDatabase database, String modelNamespace, String objectContextNamespace, String objectContextName)

  at ICSharpCode.Data.EDMDesigner.Core.Windows.EDMWizard.EDMWizardWindow.OnFinished()

  at ICSharpCode.Data.Core.UI.Windows.WizardWindowInnards.btnFinish_Click(Object sender, RoutedEventArgs e)

September 8, 2012 4:59 AM
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this ( email address.