-
-
Notifications
You must be signed in to change notification settings - Fork 97
Support for other RDBMS than SQL Server #33
Comments
This sounds like EF does a bad job of handling Oracle. Why is that? Sounds like a complaint for Microsoft. |
True, Despite that, it is not just Oracle, other providers have same problem too. That said, i was wondering if you would like to prepare it for other rdbms by allowing a plugin in there, that is the best place for it right now... |
Maybe we can change the design so these inject the DbContext. That way you can derive and do your override for ModelCreating and then the core logic can just have yours injected. I'll look into it (next week). |
Ok, the DbContexts are now injected. Give this a try and see if it works for you. |
I will check. |
Ok, just finished testing. I got from the dev branch, and running against Thinktecture.IdentityServer.v3 version="1.0.0-rc" i get an error on mapping:
Fixed it on my version on the EntitiesMap and ModelsMap, since one is AllowLocalLogin and the other is EnableLocalLogin I see that the EntityFrameworkServiceFactory has beed "disposed" :), however, there was a feature i liked, the possiblity to configure clients and scopes:
Other than that it works like a charm with some notes. OnModelCreating of the context, since it is now possible to set the schema: This will allow to set the __MigrationHistory table schema for each context, without it it will create on dbo, since we are setting the schema on the other entities. I had also to implement the totality of the RegisterClientStore, RegisterScopeStore, RegisterOperationalServices (code below), perhaps an overload to specify just the specific dbContext for each service would be wonderful. As for knowledge sharing this is what i did to make it work with Oracle (should work the same with MySql at least, ot any other with proper adjustments): ConventionsUpperCaseColumnNameConventionSince oracle has a UPPERCASE convention is is useful to set the column names in uppercase, otherwise all selects on columns will need the "ColuMnNamE" wraped in ", otherwise you wold get an error "Column does not exists".
UpperCaseForeignKeyNameConventionThis is for the uppercase the relationships columns, of by other words those columns that have foreignkeys.
UpperCaseTableNameConventionThis is for the uppercase the actual table names.
Wiring it UpCustomizationClientConfigurationDbCtx
OperationalDbCtx
ScopeConfigurationDbCtx
Turning it onIdentityServerServiceFactory Extensions
IdentityServerServiceFactory Configuration
Bonus TrackLogging InterceptorFor debuging purpose i placed an interceptor to let me see what was being generated against the RDBMS
OracleHistoryBugInterceptor
And on app.config
NotesThis was tested with Oracle ODP.Net 12c Release 3 ResourcesMicrosoftOracle Data Provider for .NETLogging and Intercepting Database OperationsCustom Code First Conventions (EF6 onwards)Thank you. |
Good feedback. Question -- are you saying that |
Hmm, I tried it and now I have conflicts -- it seems that the different DbContext classes don't want to share the migrations table if it's in a schema. |
Ok, seems that using |
I had already seen that, but was unable to reproduce. Regarding your question About the error, you can use OracleHistoryBugInterceptor, or whatever name you want. |
With an empty DB, when I use |
sorry for interrupting the conversation but since my question is the same question here I don't want to open another question, I am using oracle with entity framework 5.0 database-first approach and want to use Thinktecture v3, is it possible or not ? the thread here is talking about code-first and has a lot of info I didn't find the answer I want in previous comments. |
Well, IdentityServer should be used stand alone, so this means just because you use EF5 elsewhere, IdentityServer can use EF6. Having said that, with EF6, @LeandroPT has shown here in great detail how to get it working. |
thanks brockallen but he used code-first , is it still possible with database-first ? |
Well, unless I'm missing something from your question, if you want to use the IdSvr.Ef library, the code's already all done and it uses code first. If you want DB first, then you'd not be using this library and you're then just coding it all from scratch. |
Sorry for the delay... @brockallen I am assuming you are trying it against SQL Server. As for @mohammadhammod: What are you trying todo? |
@LeandroPT what I am trying to do is to use ThinkTecture with a very large asp.net application, this applications uses EntityFramework 5.0.0 (database first ) with oracle. I am new to ThinkTecture v3 so it seems that I asked a very stupid question! sorry for that. |
Hey @mohammadhammod, Regarding the limitation on ef with oracle provider, the answer is Not Anymore, Oracle has just released ODP.net 12c release 3 which supports ef6, so no need for ef5, and therefore this project can be now used..
It also has the link to the Oracle Site. Regarding IdentityServer, yes you can use with any ef or custom implementation, however this discussion is for @brockallen implementation on ef6 a separate project with a suggestive name :) . |
@LeandroPT i have identityServer3 working perfectly for mssql. i have been trying to migrate it by inheriting and using my own db-contexts the OperationalDbContext that has no direct implementation in the code. |
@LeandroPT @brockallen I have found the solution the above problem i indicated: solution is to specify the Schema name in the EntityFramework service options such as: |
Hello All,
Sorry about "reopening" a closed issue #2....
As Brock has probably noticed ( by my constant nagging :) ), it is difficult to use current EF code first against other RDBMS than SQL Server, in my case Oracle.
I have been able to IDSRV + EF successfully against an Oracle RDBMS by the use of a interceptor.
The disadvantage of this approach, is that it requires to parse and modify every generated query before execution, and to disableDatabaseInitialization.
The advantage however is the possibility to do about anything, including type change, name, change, whatever, without changing code, by the use of app.config
<interceptors> <interceptor type="IDS.Core.ef6.ChangeSchemaNameCommandInterceptor, IDS.Core" /> </interceptors> <contexts> <context type="Thinktecture.IdentityServer.Core.EntityFramework.OperationalDbContext, Thinktecture.IdentityServer.Core.EntityFramework" disableDatabaseInitialization="true" /> <context type="Thinktecture.IdentityServer.Core.EntityFramework.ClientConfigurationDbContext, Thinktecture.IdentityServer.Core.EntityFramework" disableDatabaseInitialization="true" /> <context type="Thinktecture.IdentityServer.Core.EntityFramework.ScopeConfigurationDbContext, Thinktecture.IdentityServer.Core.EntityFramework" disableDatabaseInitialization="true" />
I have been looking for a better way to change the schema name from the dreaded "dbo." to the oracle user, uppercase table and column names (Oracle accepts camel case, but "hand made" queries implies the use of "" in every column, and table names, which is not the "normal" for oracle developers.
The better way, is by tweaking the OnModelCreating by injecting two conventions on the "OnModelCreating" on BaseDbContext. (pretty much this: http://msdn.microsoft.com/en-us/data/jj819164.aspx)
So, for it to work, and to allow it to adjust to other RDBMS, i would like to know if you would be willing to place some kind of plug-in or (dependency injection) on BaseDbContext;
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Add<UppercaseForeignKeyNameConvention>(); modelBuilder.Conventions.Add<UppercaseTableSchemaConvention>();
base.OnModelCreating(modelBuilder);
}
The part in bold, would be whatever the user wants inside a class outside the EF assembly from a predefined interface.
Public Interface IBaseDbContextOnModelCreating
{
public void OnModelCreating(DbModelBuilder modelBuilder);
}
What is your thought on this?
The text was updated successfully, but these errors were encountered: