Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Entity Framework Perplexities
Message
General information
Forum:
ASP.NET
Category:
Entity Framework
Environment versions
Environment:
C# 5.0
OS:
Windows 10
Network:
Windows Server 2012
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01646424
Message ID:
01646520
Views:
22
>>There are a couple of add-ins which will handle transforms (but I haven't tried them) : SlowCheetah and SlowMonkey (both on nuGet)
>>
>>But I think you can subclass the DbConnectionClass, set the parameters accordingly and pass this to the DbContext constructor ?
>
>Yes, that's the plan.
>
>In fact I wanted to overload the constructor with a parameter in a partial class taht would not live in the generated project.
>
>In the Generated DBContext Project
>
>    public partial class PluczExp_PluczContext : DbContext
>    {
>        public PluczExp_PluczContext()
>            : base("name=PluczExp_PluczConnection")
>
>
>and in the production project I wanted to have
>
>
>    public partial class PluczExp_PluczContext : DbContext
>    {
>        public PluczExp_PluczContext(string connectionName)
>            : base(connectionName)
>
>
>so that I don't have to change the generated DbContext class.
>
>Have tried that before and did not work.
>
>You're suggesting to derive from PluczExp_PluczContext , but then I'm not sure how I call the base (red in the cheeks).
>Thanks for shedding some light on this.

You could :
   public partial class PluczExp_PluczContext  : DbContext
    {
        public PluczExp_PluczContext (): base("name=PluczExpEntities") {}

        public PluczExp_PluczContext (string ConnectionName): base("name="+ConnectionName) {}
    }
so instantiating the context with an empty constructor would use the "PluczExpEntities" connection name in app.config and instantiating with
PluczExp_PluczContext  PGD = new PluczExp_PluczContext ("PluczExpEntities2");
would use the connection named 'PluczExpEntities2'. In app.config just copy the default, rename and adjust.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform