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

DbContext

May 9, 2012 at 10:11 AM

Am I understanding this correctly, Effort uses objectcontext?

How does this affect project that are using dbcontext instead? Are there plans of supporting both?

May 11, 2012 at 10:08 AM

Hello,

If you download the whole source code, you will find an Effort.CodeFirst project too that gives you DbContext support. Unfortunatelly the author of this project does not have much free time, so it lacks tutorials or demo projects. But since this feature might become more important (especially with the release of .NET4.5), I am going to dig in and create some documentation in the near future.

Thanks for the feedback,
Tamas

Jun 7, 2012 at 12:18 AM
Edited Jun 7, 2012 at 12:18 AM

Today I have uploaded a beta release that has Code First support. Here you can a find a tutorial about it:

http://effort.codeplex.com/wikipage?title=Create%20a%20fake%20DbContext%20instance

I would appreciate if you could try it and let me if it works properly.

Sep 27, 2012 at 4:29 PM
Edited Sep 27, 2012 at 4:32 PM

Hello,

Does it support database/model first, too?

Thanks

Sep 27, 2012 at 4:44 PM

Of course, just consider using Effort.EntityConnectionFactory or Effort.ObjectContextFactory. However, contrary to the Code First approach, they require the presence of a connection string that references the appropriate EDMX metadata files.

Sep 28, 2012 at 11:58 AM
Edited Sep 28, 2012 at 4:47 PM

Hi Tamas,

Thanks for the quick response.


As you advised, I am using EntityConnectionFactory (new MyContext(EntityConnectionFactory.CreateTransient("name=MyConnection"))) to initialize my context instance (my context derives from DbContext), but it throws a MetadataException with the following message:

Message:
Schema specified is not valid. Errors:
(0,0) : error 0040: The Type nvarchar is not qualified with a namespace or alias. Only primitive types can be used without qualification.
...

I figured it out that the root cause is in the EffortProviderManifest, because the EffortProviderManifest.xml file does not contain the definitions of types used in my existing storage model (eg. nvarchar) which in my case are MS SQL Server specific data types.

So I decided to extend the EffortProviderManifest with the data types supported by the SqlClient ProviderManifest, but unfortunately this caused an ArgumentException inside the NMemory module with the following message: "The type of 'SHORTCUT' property is 'System.Byte[]', use 'NMemory.Data.Binary' instead. Parameter name: TEntity"

What am I doing wrong?


Thanks,
Botond

Sep 28, 2012 at 12:11 PM
Edited Sep 28, 2012 at 12:13 PM

Might I ask you to open a new Issue for this? Give a title something like this: "Full MS SQL type support". I will provide more info there.

Sep 28, 2012 at 4:49 PM

Issue created: http://effort.codeplex.com/workitem/671