Is there a way to not have the EF Core define the connection string OR have it try to get from a local app settings? I'm using dependency injection and this is being passed in via the option builder parameter.
Basically, I want this line to be commented out when the template generates!
https://www.dropbox.com/s/rlhtx6wikaxhc ... g.png?dl=0
EF Core Context
Re: EF Core Context
Please open your *.efml model via Solution Explorer of your Visual Studio, double click the diagram surface to open Model Settings and select the "Use the following connection string from App.Config". Save the model to regenerate the code. Is that what you need?
Code: Select all
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(GetConnectionString("myModelConnectionString"));
CustomizeConfiguration(ref optionsBuilder);
base.OnConfiguring(optionsBuilder);
}
private static string GetConnectionString(string connectionStringName)
{
System.Configuration.ConnectionStringSettings connectionStringSettings = System.Configuration.ConfigurationManager.ConnectionStrings[connectionStringName];
if (connectionStringSettings == null)
throw new InvalidOperationException("Connection string \"" + connectionStringName +"\" could not be found in the configuration file.");
return connectionStringSettings.ConnectionString;
}
Re: EF Core Context
No, I don't have an app.settings for this project. I'm injecting the connection string info into this from MVC via the Startup.cs, so I don't want it to know anything about the connection string.
Code: Select all
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddDbContext<IQContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("IqConnectionString")), ServiceLifetime.Scoped);
Re: EF Core Context
Please modify a predefined EF Core template by removing the lines 1017 and 1022.
More information:
More information:
- https://www.devart.com/entitydeveloper/ ... eloper.chm (download, right click > Properties > Unblock), navigate to the "Template System Concepts" section
- you can use IntelliSense feature in our T4 Editor (completion list appears when you type the '.' character)
Re: EF Core Context
When I try to make a template into a user template it blows up EntityDeveloper. I have a support ticket in and I haven't gotten any response on it yet
Re: EF Core Context
Anytime I try to generate with a template other than the built-in EF Core, I get this error.
Even without changing the template once I make it into a user template it blows up.
Even without changing the template once I make it into a user template it blows up.
Re: EF Core Context
We have asked for the additional information by email.